[SalesForce] How to fix the error on deploying the apex classes using VS code

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')

enter image description here

Best Answer

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.

New Apex Class

Related Topic