C:\Users\Aly>npm --version
'CALL "C:\Program Files (x86)\nodejs\\node.exe" "C:\Program Files `(x86)\nodejs\\`
node_modules\npm\bin\npm-cli.js" prefix -g' is not recognized as an internal or external command,operable program or batch file.
3.10.9
Windows 10
Thanks So Much In Advance
–
I just spend way to long with this issue. I'm not sure how it got set, perhaps during an install, but I changed a System Variable:
Name: ComSpec
Value: %SystemRoot%\system32\cmd.exe;prefix=C:\Program Files (x86)\nodejs\node.exe
To this:
Name: ComSpec
Value: %SystemRoot%\system32\cmd.exe
And restarted my system and the issue was gone.
Good catch blur0224.
I also spent way too long on this issue reinstalling node
in various ways and investigating administrator privileges
for the %appdata%/roaming/npm -folder
.
Your solution worked for me also. The ComSpec variable
contained old trash (referring to uninstalled programs) which somehow interfered when calling npm.
Side note 1: What was REALLY confusing was that calling npm worked for many npm package retrievals, but not all. Error code in the failed cases would for me contain keywords such as code ELIFECYCLE
and errno ENOENT
.
Side note 2: I also received warning 1909 could not create shortcut node.js command prompt.lnk
when installing node - perhaps implying that an environmental variable was not properly installed.
Anyone seeing the symptoms from the two previous paragraphs could try the answer from blur0224. I hope this helps people searching for these keywords.
–
Firstly, check using GitBash whether the npm -v
command executes successfully.
If NPM is working in GitBash, then it is not a path problem (your path reference is OK).
Go to Environment Variables > System Variables and check if ComSpec: %SystemRoot%\system32\cmd.exe
is correctly configured, or not.
In some cases, if you have a trailing slash, it will not work. (eg: ComSpec : %SystemRoot%\system32\cmd.exe\
) If so, simple remove the trailing slash.
Otherwise, check where cmd.exe
is located and use that path as the ComSpec
value.
Usually, it resides at c://Windows/System32/cmd.exe
.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.