How to delete a Lightning Web Component?

Make sure that you have the most updated CLI version. On your terminal or command line use this:

sfdx force:source:delete -p <path-to-the-component-folder-on-your-machine>

It will ask you if you are sure, type y. And there you are.


Assuming you have already set up Visual Studio Code and installed the necessary extensions: Salesforce VS Code Extensions

It is as easy as right click the folder in VS Code to delete > SFDX: Delete From Project and Org

SFDX: Delete From Project and Org

Note: If you accidentally renamed your LWC in VS Code and pushed it into your org (e.g. Renamed "LWC_Eample" to "LWC_Example"), the old LWC "LWC_Eample" will still be visible in your SFDC org but not present in your VS Code.

If this happens, go to your VS code project, Right Click your "Manifest > Package.xml" > Retrieve Source in Manifest from Org.

Presto, your old LWC "LWC_Eample" will appear in VS code. Then you can proceed to SFDX: Delete From Project and Org