Newer Version Available
Error: No defaultdevhubusername org found
But when you try to create a scratch org another time using the same CLI command, you get this error:
1Unable to invoke command. name: NoOrgFound message: No defaultdevhubusername org foundWhat happened?
Answer: You are no longer in the directory where you ran the authorization command. The directory from which you use the --setdefaultdevhubusername parameter matters.
If you run the authorization command from the root of your project directory, the defaultdevhubusername config value is set locally. The value applies only when you run the command from the same project directory. If you change to a different directory and run force:org:create, the local setting of the default Dev Hub org no longer applies and you get an error.
Solve the problem by doing one of the following.
-
Set defaultdevhubusername globally so that you can run force:org:create from any directory.
1sfdx config:set defaultdevhubusername=<devhubusername> --global -
Run force:org:create from the same project directory where you authorized your Dev Hub org.
-
Use the --targetdevhubusername parameter with force:org:create to run it from any directory.
1sfdx force:org:create --definitionfile <file> --targetdevhubusername <devhubusername> --setalias my-scratch-org -
To check whether you’ve set configuration values globally or locally, use this command.
1sfdx config:list