Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while running npm "prefix -g is not recognized as an internal or external command"

Tags:

node.js

'CALL "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" prefix -g' is not recognized as an internal or external command, operable program or batch file.

I am using windows 8.1 enterprise version, and I have my files in appdata/npm still I am getting the above error. I installed the latest node version,i.e, v6.3.0 and I've even tried with the older version of node ,i.e, v4.4.7 and I am getting the same error.

like image 351
Har Avatar asked Oct 18 '22 06:10

Har


2 Answers

I had the same issue. Mine also printed this issue.

error file C:\Windows\system32\cmd.exe;

seems I screwed up my comSpec in my environmental variables.
The ";" at the end of that line was causing the error.

like image 84
Drew B Avatar answered Oct 21 '22 06:10

Drew B


Not sure if still have the same the problem but recently I was experienced this annoying error and finished solving by modified the npm.cmd file found in nodejs installation folder. It seems the error occurs because a wrong use of apostrophes and double quotes when calling the npm.cmd file. By default the npm.cmd comes in this way:

'CALL "%NODE_EXE%" "%NPM_CLI_JS%" prefix -g'

You need to change that to

"CALL ""%NODE_EXE%"" ""%NPM_CLI_JS%"" prefix -g"

In that way the .cmd must be executed correctly, or at least work for me in Windows 10 OS.

Hope it helps.

like image 41
fedeO Avatar answered Oct 21 '22 05:10

fedeO