I am trying to follow the Trailhead module on CI and Salesforce DX. I tried to push some of my Lightning components which depend on a managed package in App Exchange. I would like to know how to install a managed package using Salsforce DX CLI so that i can use that command in my travis.YML file for my CI integration.

Here is the script for my Travis file

sudo: true
dist: trusty
cache: false
- URL=https://developer.salesforce.com/media/salesforce-cli/sfdx-linux-

- export SFDX_DOMAIN_RETRY=300
- wget -qO- $URL | tar xJf -
- "./sfdx/install"
- export PATH=./sfdx/$(pwd):$PATH
- sfdx update
- sfdx force:auth:jwt:grant --clientid $CONSUMERKEY --jwtkeyfile 
--username $USERNAME --setdefaultdevhubusername -a DevHub
- sfdx force:org:create -f config/project-scratch-def.json -s -a 
- sfdx force:org:list
- sfdx force:org:display
- sfdx force:user:password:generate -u PackageInstallation
- sfdx force:org:display
- sfdx force:org:open -u PackageInstallation
- sfdx force:source:push -u PackageInstallation
- sfdx force:apex:test:run -u PackageInstallation -c -r human

I get the following error as my components depend on the app exchange components:

No COMPONENT named markup://ldt:datatableDev found :

3 Answers 3


This helped me get the right id for app exchange packages currently installed in my devhub:

$ sfdx force:package:installed:list -u [DevHubAlias]

=== Installed Package Versions [2]
──────────────────  ──────────────────  ─────────────────────  ─────────  ──────────────────  ────────────  ────────
0A346000000qUm7CAE  03336000000DlP2AAK  HEDA                   hed        04t360000011zP6AAI  HEDA 1.43
0A346000000H6SeCAK  033C00000006mUuIAI  Apsona for Salesforce  apsona     04tC0000000ggXVIAY  Update

$ sfdx force:package:install -p 04t360000011zP6AAI -u scratch -w 5

Note: use the -p parameter instead of the old -i param.

Note: the HEDA package I am installing also required some additional setup in the scratch org before I could install it. Specifically I had to create a dummy account record type.

  • This is really helpful, thanks! ..one question I have, does this package now need to be added to the sfdx-project.json file? I seem to be unable to create a package version due to components from managed packages on lightning record pages. I can push to a scratch org ok, but only once I have installed the managed package.
    – Jay
    Commented Jul 30, 2019 at 15:42
  • 1
    ^^ I found my answer here: salesforce.stackexchange.com/questions/252540/…
    – Jay
    Commented Jul 30, 2019 at 16:03

To install a First Generation Managed Package via sfdx, you do it the same way you do it with the metadata API. The command looks like this:

sfdx force:mdapi:deploy -d packages

The packages folder contains a package.xml file with the following contents:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">

The packages folder should contain a sub-folder named installedPackages. Within that folder, you should have installedPackage files that contain data like the following:

<?xml version="1.0" encoding="UTF-8"?>
<InstalledPackage xmlns="http://soap.sforce.com/2006/04/metadata">

Password is optional unless required by the package.

The file name for the package will be namespace.installedPackage. For example, since your package's namespace is ldt, the file name would be ldt.installedPackage.

You can install multiple packages in a single deployment. Each package can succeed/fail independently of the others.

This will not work for Second Generation Managed Packages. For those, use the sfdx force:package:install command. You can write a shell script to automate installing many packages in a preferred order of dependencies.

  • @ak_1 You should have a folder (I called it packages), the file packages\package.xml (with the contents from this answer), and the file packages\installedPackages\ldt.installedPackage (that contains the second XML block). You need the version number obtained from setup in the <version>X.XX</version>.
    – sfdcfox
    Commented Jul 25, 2017 at 22:59
  • thanks for immediate response clearly this links explains [developer.salesforce.com/docs/atlas.en-us.packagingGuide.meta/… the same which i am able to follow more clearly with your explaination. thank you
    – ak_1
    Commented Jul 25, 2017 at 23:05
  • Hi @sfdcfox this exactly worked for me thanks for your help!
    – ak_1
    Commented Jul 26, 2017 at 0:43
  • @ak_1 I'm glad I was able to help you out.
    – sfdcfox
    Commented Jul 26, 2017 at 0:53
  • 1
    @TusharSharma You need either the version number or the ID. If you're using the technique in this answer, you need the version number and the password, if protected. If you're using force:package:install, you need the package version ID, but not the version itself. If you're not sure what version you have, you can retrieve them via InstalledPackage or force:package:installed:list.
    – sfdcfox
    Commented Oct 4, 2018 at 12:08

Have you tried using:

sfdx force:package:install -i 04t6A0000004eytQAA

Docs for this are found in the CLI command reference.

The only thing is that you'd need to know the ID of the package to pass to the command, but if you can get that, you should be in good shape.


After doing some playing around with this now, when you run the install of an app exchange managed package through the UI, the package Id (or rather, the package version Id if I'm not mistaken) is shown in the address bar of your browser.

Please do not consider this an endorsement of Skuid. I have no affiliation to them, rather it was the first package that came to mind.

This is the value you need to supply. Taking that Id value, I have now successfully done the following:

$ sfdx force:project:create -n test-project
target dir = /Users/pchittum/Stuff/git/sfdx-pilot
   create test-project/sfdx-project.json
   create test-project/README.md
   create test-project/config/project-scratch-def.json

$ cd test-project/
$ sfdx force:org:create -f config/project-scratch-def.json -s 
Successfully created scratch org: 00D0v0000008eXmEAI, username: test-mffvsibtb6ly@pchittum_company.net

$ sfdx force:package:install -i 04t4A000000cESSQA2 
PackageInstallRequest is still InProgress or Unknown. You can query the status using
sfdx force:package:install:get -i 0Hf0v0000008QWdCAM 

$ sfdx force:package:install:get -i 0Hf0v0000008QWdCAM 
Successfully installed package [04t4A000000cESSQA2]

Please note I have no affiliation with the above AppExchange partner. It was just the first thing that came to mind.

  • Hi @pchittum i tried to use this command since i dont have the packageid for the apps in app exchange i am not sure, how to use this command. Do you have any idea of how to get the package id for app exchange apps. i tried to use the id in the app exchange but that didnt work
    – ak_1
    Commented Jul 25, 2017 at 22:23
  • I just updated my answer with what I found.
    – pchittum
    Commented Jul 26, 2017 at 7:56
  • Hi @pchittum, yeah this helps me as i tried to use the listingid in the app exchange instead we need to use the appid while installing. Thanks for your detailed explaination.
    – ak_1
    Commented Jul 26, 2017 at 16:49
  • Using the that id, installs FormulaForce (Managed) package and not 'skuid' for me. Its gonna make it even harder to not have a consistent ID @pchittum,
    – OK999
    Commented Nov 22, 2017 at 16:20
  • Tried as suggested by @havana59er, get the list from the devhub. $ sfdx force:package:installed:list -u DevHub === Installed Package Versions [1] ID PACKAGE ID PACKAGE NAME NAMESPACE PACKAGE VERSION ID VERSION NAME VERSION ────────────────── ────────────────── ──────────── ───────── ────────────────── ─────────────────── ──────── 0A31I000000LOtXSAW 033G00000006ShvIAE Skuid skuid 04t4A00000042DGQAY Skuid Millau (11.0) .. but fails too using the ID from the DeHub
    – OK999
    Commented Nov 22, 2017 at 16:45

You must log in to answer this question.

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