Installing an appexchange app into a scratch org

Figured it out. You cannot use the sfdx force:package:install command using the ID of the appexchange app. The ID that is needed is eventually displayed in the URL during an interactive install of the app into a non-scratch org (at the step where you are asked to select which users should be granted access to the app). For example, the URL for the "Salesforce Community Management Package for Communities with Chatter":


The package ID needed is the value of the apvId parameter (04to00000007jkAAAQ). Feed this into the sfdx command like so:

  • sfdx force:package:install --id 04to00000007jkAAAQ -w 1000

More details about obtaining the package ID:


Just in case to help anyone in the future, you also can obtain the package version ID installed in any org with:

sfdx force:package:installed:list -u <alias|username>

The output for a Nonprofit Success pack as example:

ID                  Package ID          Package Name                    Namespace      Package Version ID  Version Name               Version
──────────────────  ──────────────────  ──────────────────────────────  ─────────────  ──────────────────  ─────────────────────────  ──────────
0A32E000000rQnwSAE  033i0000000Gi57AAC  Nonprofit Success Pack          npsp           04t1Y000000ggZ2QAI  Cumulus          

So you can install it with:

sfdx force:package:install -p 04t1Y000000ggZ2QAI -u <scratchOrg> -w 1000

In case you need to install more than one, just add the -r parameter for no prompt, and add && to concat commands.

sfdx force:package:install -p 04t1Y000000ggZ2QAI -u <scratchOrg> -w 1000 - r &&
sfdx force:package:install -p 04t1Y000000ggZ2QAI -u <scratchOrg> -w 1000