6

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.

Is there any sfdx command something like

sfdx force:lightning:lwc:delete -someflag lwcName

Thanks!

4
  • can you try this? sfdx force:source:delete -m LightningComponentBundle:componentName -r Feb 20, 2019 at 11:12
  • @PranayJaiswal I have this error ERROR: The LightningComponentBundle named my lwc name was not found in the workspace. Feb 20, 2019 at 11:17
  • whats your version of SFDX cli? Feb 20, 2019 at 11:18
  • @PranayJaiswal everything is up to date. @salesforce/plugin-generator 1.0.1 (core) @salesforce/sfdx-trust 2.0.1 (core) builtins 1.0.0 (core) salesforcedx 45.0.12 (pre-release) sfdx-cli: 6.53.0-67a9cbb60c Feb 20, 2019 at 11:21

2 Answers 2

3

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

5
  • nice update, thanks Oct 17, 2019 at 11:43
  • It's worth observing the sfdx commands this plugin runs in your terminal. You can do more with the sfdx command than with this VSCode only plugin. Jun 15, 2020 at 4:59
  • @JanWerkhoven I've been seeing alot of answers that just post "sfdx force:.." but none really give an example on how to execute it. If I try execute those commands I always get error
    – compski
    Jun 16, 2020 at 5:05
  • You first need to install the sfdx binary on your device. On Mac, open your terminal and type: brew install sfdx and after that you should be able to run sfdx --help. Jun 16, 2020 at 8:16
  • When I try this delete method, I'm getting an error Warning destructiveChanges.xml No LightningComponentBundle named: myLWCfolder found. I'm not sure how to create the bundle. I've retrieved the source from org using my manifest which references the LWC component already, but the error persists.
    – Garywoo
    Oct 11, 2022 at 15:00
10

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.

1
  • I'm trying to delete the component from a Production org, getting the following error: "INVALID_OPERATION: testLevel of NoTestRun cannot be used in production organizations." Any ideas on how to change the testLevel used behind the scenes for this SFDX delete command? I don't see a command parameter for it in the documentation Jul 11, 2019 at 21:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .