A few days back an npm package for base lightning components was released
Base Lightning Components
With this I am expecting to use base lightning components like my favorite lightning-datatable in a node project.
But getting following error for adding Lightning Button
⚡⚡⚡⚡⚡ Lightning Web Components ⚡⚡⚡⚡⚡
� Starting build process.
� Local server listening: http://localhost:3001
× 「wdm」:
ERROR in ./src/modules/lightning/primitiveIcon/primitiveIcon.js
Module not found: Error: Can't resolve '@salesforce/i18n/dir' in 'E:\Temp Codes\lwc oss with base components\my-app\src\modules\lightning\primitiveIcon'
@ ./src/modules/lightning/primitiveIcon/primitiveIcon.js 3:0-39 34:60-63
@ ./src/modules/lightning/button/button.html
@ ./src/modules/lightning/button/button.js
@ ./src/modules/my/greeting/greeting.html
@ ./src/modules/my/greeting/greeting.js
@ ./src/modules/my/app/app.html
@ ./src/modules/my/app/app.js
@ ./src/index.js
@ multi ./node_modules/error-overlay-webpack-plugin/lib/entry-basic.js ./node_modules/error-overlay-webpack-plugin/lib/entry-devserver.js? ./src/index.js
Best Answer
Looks like you are using the create lwc app to create the project scaffold.
There are a few things you need to make sure,
Make sure you have installed the lightning-base-components via npm install
npm install lightning-base-components
Ensure that your lwc.config.json has the npm dependency specified
Make sure you install the SLDS using
Make sure you have lwc-services.config.js properly configured
Add the SLDS styles in your index.html at the head
import @lwc/synthetic-shadow
in your index.js. Ensure the import is the first statement in your index.js file, else the synthetic shadow may not work