How to install any package in pwa studio project

Viewed 259

I am working on the PWA studio Magento project and it's my first time working with PWA studio. I don't know how to install the package in the PWA studio project. When I got the project and it was working fine but when I add a new npm package and import and use it and then when I run yarn run watch:siminia it shows me an error.

How I Installed the package

I just navigate to my project folder
I installed the package here

projectfolder/packages/siminia/

and used it in

projectfolder/packages/siminia/src/simi/App/Bianca/RootComponents/Product/ProductFullDetail/ProductImage/index.js

and after that i run yarn run watch:siminia it shows me an error

TypeError: Cannot read property 'type' of undefined
    at Parser.match (/home/bilal/Desktop/biancanera/node_modules/@magento/directive-parser/src/Parser.js:67:22)
    at Parser.parseDirective (/home/bilal/Desktop/biancanera/node_modules/@magento/directive-parser/src/Parser.js:43:19)
    at Parser.parse (/home/bilal/Desktop/biancanera/node_modules/@magento/directive-parser/src/Parser.js:29:14)
    at module.exports (/home/bilal/Desktop/biancanera/node_modules/@magento/directive-parser/src/Parser.js:168:58)
    at comments.reduce (/home/bilal/Desktop/biancanera/node_modules/@magento/directive-parser/src/index.js:12:38)
    at Array.reduce (<anonymous>)
    at parseDirectives (/home/bilal/Desktop/biancanera/node_modules/@magento/directive-parser/src/index.js:11:40)
    at Promise.all.rootComponentFiles.map (/home/bilal/Desktop/biancanera/packages/siminia/node_modules/@magento/pwa-buildpack/dist/WebpackTools/plugins/makeMagentoRootComponentsPlugin/index.js:75:13)
Done in 4.50s.

I don't know what I am doing wrong.

1 Answers

You should create a separate folder for add-on packages. You can then call the add-on module from the local-intercept.js file in your pwa project. If the siminia folder is the main folder containing the pwa code, you should create another folder at the same level as the siminia and copy the entire code of the add-on module into it.

Related