+ Start a Discussion
Praneeth Jonna 2Praneeth Jonna 2 

sfdx scratch org creation on windows 7 with username containing space

Following command is not working when the default windows username contains a space example (C:\users\John Smith)
sfdx force:org:create -s -f config/project-scratch-def.json -a "default scratch org"

Error is ''C:\Users\John' is not recognized as an internal or external command,
operable program or batch file.

 
Praneeth Jonna 2Praneeth Jonna 2
Node has to be install globally for all users.

Choose C:\ProgramData\nodejs as installation directory for nodejs and install nodejs with any user that is a member of the administrator group.
Create a folder called npm-cache at the root of the installation directory, which after following above would be C:\ProgramData\nodejs\npm-cache.
Create a folder called etc at the root of the installation directory, which after following above would be C:\ProgramData\nodejs\etc.
Set NODE environment variable as C:\ProgramData\nodejs.
Set NODE_PATH environment variable as C:\ProgramData\nodejs\node_modules.
Ensure %NODE% environment variable previously created above is added (or its path) is added to %PATH% environment variable.
Edit %NODE_PATH%\npm\npmrc with the following content prefix=C:\ProgramData\nodejs
From command prompt, set the global config like so...
npm config --global set prefix "C:\ProgramData\nodejs"
npm config --global set cache "C:\ProgramData\nodejs\npm-cache"
It is important the steps above are carried out preferably in sequence and before updating npm (npm -g install npm@latest) or attempting to install any npm module.

After this install sfdx-cli from npm
 
Josip KrajnovićJosip Krajnović
This worked for me:

It would seem that SFDX does not handle spaces in the LOCALAPPDATA environment variable.

The workaround is to use short names. In a command line, execute:
FOR %d IN ("%LOCALAPPDATA%") DO SET LOCALAPPDATA=%~sd

This command line is then ready for SFDX use.

Note : in a batch file, do not forget to double the % sign.