Help me to fix this error
'SFDX: Deploy This Source to Org' resulted in an error (c:\force-\main\default\classes\ChangePasswordController.cls: Metadata xml file missing for 'LightningComponentBundle')
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityHelp me to fix this error
'SFDX: Deploy This Source to Org' resulted in an error (c:\force-\main\default\classes\ChangePasswordController.cls: Metadata xml file missing for 'LightningComponentBundle')
The error means you're missing a metadata file. On the file explorer, click on the New File button, and name it:
ChangePasswordController.cls-meta.xml
And give it the following contents:
<?xml version="1.0" encoding="UTF-8'?>
<ApexClass xmlns="http://soap.sforce.com/2006/04">
<apiVersion>49.0</apiVersion>
<status>active</status>
</ApexClass>
Save, then deploy your class again.
Odds are, the file may have been accidentally deleted or you forgot to create this file. When creating a new Apex Class in VS Code, you should use the SFDX: Create Apex Class command option (right-click on the classes
folder to find this menu item), instead of manually creating the file.
The easiest solution is to create a new Apex Class via VS Code as per sfdcdox's answer above, then copy the contents of your file 'LightningComponentBundle' into it. Delete the original from Project and Org and then rename your new class as needed.
Alternatively you can create the class via the developer console in your org and then retrieve the metadata as normal in VS Code.