Friday 29 May 2020

Lightning Web Components Errors & Fixes

1. SFDX: Create Project.

Error :
09:47:54.651 sfdx force:project:create --projectname
HelloWorldLightningWebComponent --outputdir c:\LWC --template standard
ERROR running force:project:create:  Command failed with
exit code 1: npm root -g --prefix c:\LWC\.yo-repository --loglevel error
'npm' is not recognized as an internal or external command,
operable program or batch file.
09:47:57.138 sfdx force:project:create --projectname
HelloWorldLightningWebComponent --outputdir c:\LWC --template standard
 ended with exit code 1

Fix : Update the CLI
VS Code --> Terminal --> SFDX Update

2. SFDX: Update
Error :  Channel "stable" not found.
Fix : Close the visual studio and open again try to execute the command,It solved for me.

3. SFDX: Scratch Org Creation
Error :  running force:org:create:  Error authenticating with the refresh token due to:                   expired access/refresh token
Fix : First Authenticate the Dev Hub login & Then try to create scratch org
sfdx force:auth:web:login -d -a DevHub sfdx force:org:create -d 30 -s -a eslwc -f config/project-scratch-def.json

4. Handling Server Errors Example Implementation

Error :  No Module named markup://c:ldsUtils found :[markup://c:accountList]

Fix :      First deploy the “ldsUtils” to source org and then try to deploy “accountList”

5. Set Up Jest Testing Framework
Error : npm ERR! request to https://registry.npmjs.org/@salesforce%2fsfdx-lwc-jest failed, reason: self signed certificate in certificate chain
while executing "sfdx force:lightning:lwc:test:setup"
Fix : Execute below command 1st
npm config set strict-ssl false

5. How to retrieve component from Salesforce to Visual Studio ?
Ex: Retrieve boatMap component from Salesforce to VS
sfdx force:source:retrieve -m LightningComponentBundle:boatMap

To get project specific :

sfdx force:source:retrieve -p C:\LWC\BoatSearch-LWC-SP\force-app\main\default\lwc -u vscodeOrg


To get all the LWC comp :

sfdx force:source:retrieve -m LightningWebComponentBundle


No comments:

Post a Comment