Suppose to have deployed a lightning web component with a wrong file in its folder structure.

└── lwcExample/
    ├── WRONG_FILE.html
    ├── lwcExample.html
    ├── lwcExample.js
    └── lwcExample.js-meta.xml

How can you delete from org the wrong file without deleting the component?

Note that the wrong file doesn't have any dependency while the other files might have it. Thus, it is preferable to avoid deleting the whole component and creating it without the wrong file.

I tried to delete it through sfdx with the following command but it tries to delete the whole component.

sfdx force:source:delete --sourcepath "force-app/main/default/lwc/lwcExample/WRONG_FILE.html"

1 Answer 1


Just delete the file and then redeploy the component. With SFDX, you can use force:source:push, force:source:deploy, force:mdapi:deploy, or force:package:version:create and then force:package:install. The component bundle is considered "atomic," meaning the entire component is deployed at once, including all individual files, so deleting the file and deploying the change in any manner will suffice.

You must log in to answer this question.

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