How do I create a scratch org that has the same namespace as my Developer Edition org where the managed package is held?

I've followed the instructions in the "Link a Namespace to a Dev Hub Org" page to link the namespace to my Dev Hub org, but I cannot find any instructions on any of the documentation pages below for how to actually create a new scratch org that has the same namespace as my DE org.


In the project configuration file, specify the namespace.

"packageDirectories" : [ 
    { "path": "force-app", "default": true}
"namespace": "myns", 
"sfdcLoginUrl" : "https://login.salesforce.com", 
"sourceApiVersion": "44.0"

This really only alluded to in the documentation, but sfdx-project.json is the key to creating a scratch org with a namespace.

  • 1
    Also worth noting that the namespace has to be registered in your dev org, otherwise you'll get a cryptic error message about some kind of standard javascript name, IIRC. – berry120 Sep 28 '18 at 20:38
  • Beautiful. Worked like a charm! – Marty C. Oct 1 '18 at 15:50
  • Thanks for clarifying. I would totally expect the namespace setting to be in the scratch org definition file, and not the project file. So confusing. – Charles Naccio Jun 9 at 19:53

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.