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.

| improve this answer | |
  • 2
    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
  • 1
    Beautiful. Worked like a charm! – Marty C. Oct 1 '18 at 15:50
  • 1
    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 '19 at 19:53
  • @sfdxfox- i need to create a scratch org without namespace. Would I then just make namespace field blank? – Seyitbek Oct 22 '19 at 16:39
  • 1
    @Seyitbek yes, use the empty string ("") to denote that there is no namespace. – sfdcfox Oct 22 '19 at 16:59

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.