Salesforce logSalesforce

Deploy a Package with SFDX

Push and deploy package source code to your Dev Hub org using SFDX commands.
Available in: Lightning communities accessed through Lightning Experience in Enterprise, Unlimited, and Developer editions.

  1. In Visual Studio Code, open the Command Palette by pressing Ctrl+Shift+P (Windows) or Cmd+Shift+P (macOS).
  2. Enter SFDX: Push Source to Default Scratch Org.
  3. To create the package, enter sfdx force:package:create -n PACKAGENAME -t Unlocked -r force-app —nonamespace.
  4. To create the package version, from the command line inside the project directory, enter sfdx force:package:version:create -p PACKAGENAME -d force-app -v DEVHUBUSERNAME -k 123456 --skipvalidation —-wait 10, where DEVHUBUSERNAME is the name of your authorized Dev Hub.
  5. To install the package, enter sfdx force:package:install --package <PACKAGENAME> --targetusername <>, where is the System Administrator’s username.
    You can optionally install the package from the B2B2C Commerce app. To do so, for Step 4, create the package version and copy the returned installation URL, which looks like this: Replace the host in the URL with the host of the scratch org you’re deploying to.
  6. To retrieve the metadata in package format, enter sfdx force:mdapi:retrieve -s -r ~/Documents -u MYSCRATCHORG -p PACKAGENAME.
    Make sure that the -u variable is the name of the org where you installed the package in the previous step.