function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
EvgeniyEvgeniy 

How to delete Lightning Web Component?

I'm trying to delete new Lightning Web Component without any luck.
I've tried to find it in Dev Console, but as you know it doesn't support Lightning Web Components yet. Another way I've tried to delete my lwc in VS Code and just deploy source to sandbox, but it still there in my sandbox org and I can see it in Lightning App Builder and when I try to retrieve source I see this error
ERROR: Cannot read property 'fileName' of undefined.

But as mentioned here this should be fixed tomorrow https://github.com/forcedotcom/cli/issues/33

So for now I have it in org but don't have in VS Code.

Thanks!
Best Answer chosen by Evgeniy
Khan AnasKhan Anas (Salesforce Developers) 
Hi Evgeniy,

Greetings to you!

Please make sure you are using the latest version of salesforcedx. To work with Lightning web components, you need version 45 or greater of the Salesforce CLI. Check the installed version.

sfdx plugins --core

NOTE: If you had a prerelease version of the CLI installed, run this command to update it.
sfdx plugins:install salesforcedx@latest

Please refer to the below link which might help you further with the above requirement.

https://www.developer.atsiro.com/2019/01/23/lwc-part-3/

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas 

All Answers

Khan AnasKhan Anas (Salesforce Developers) 
Hi Evgeniy,

Greetings to you!

Please make sure you are using the latest version of salesforcedx. To work with Lightning web components, you need version 45 or greater of the Salesforce CLI. Check the installed version.

sfdx plugins --core

NOTE: If you had a prerelease version of the CLI installed, run this command to update it.
sfdx plugins:install salesforcedx@latest

Please refer to the below link which might help you further with the above requirement.

https://www.developer.atsiro.com/2019/01/23/lwc-part-3/

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas 
This was selected as the best answer
EvgeniyEvgeniy
Thank you. Still weird for me that Salesforce doesn't provide more simple solution for such basic operation.
Raj VakatiRaj Vakati
Deleting LWC is very easy and i am not sure why you need to do all this .. 

Step 1 : Go to You VS code workspace and find the component  and Delete the LWC folder 

User-added image

Step 2: Push the changes using SFDX 
 
sfdx force:source:push --forceoverwrite

User-added image


And Now component will be deleted

User-added image

 
Raj VakatiRaj Vakati
LWC Development is Depends on SFDX so if you delete the LWC folder in the SFDX Org it will be deleted in Salesforce
Amanda Fouts 30Amanda Fouts 30
I was able to easily delete a lightning web component through running this query in the dev console with the tooling API checkbox checked:
SELECT Id, apiversion, developerName, FullName, targetConfigs FROM LightningComponentBundle where developerName = 'myComponent'
Select the row from the query results, then click the "Delete Row" button on the query grid. 
Asif Ali MAsif Ali M
just in case if anyone lands on this post again.... the latest version of VS Code has the option to delete LWC. Right click the LWC directory and you will see the Delete option. which will delete the source and then delete it from the Org 
User-added image