3

My unlocked package (DX project) depends on a package from the app store, so a managed package.

How do I correctly specify this in the project file? During development I've manually installed the package in every scratch org, but it fails during package:version:create. I guess it is the dependency that fails...

3

On the commandline, find the package ID of the managed package you depend on. You can list all packages like this:

sfdx force:package:installed:list -u ORG_ALIAS_EG_PROD_OR_SANDBOX

Then you'd just add this to the dependency section (the Id starting with 04t...) e.g.

"dependencies": [
    {
       "package": "PACKAGE_ID_HERE"
    }
],

I've also seen examples where you'd use package aliases, but it seems to do the same:

"dependencies": [
    {
       "package": "some_alias_here"
    }
],

...
packageAliases : {
    "some_alias_here":"04t........."
}

Anyway, even with all the dependencies correct, remember that, at the time of writing (Sep'18), unlocked packages is still in beta so not everything may work, at least id didn't for me.

3
  • Which file are you putting that in?
    – cal5barton
    Feb 12 '19 at 20:52
  • I think it was config/project-scratch-def.json.
    – specimen
    Feb 13 '19 at 8:51
  • @cal5barton this goes into sfdx-project.json under packageDirectories[<myPackage>].dependencies Apr 23 '20 at 8:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.