5
votes

'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.

5

5 Answers

2
votes

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.

1
votes

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.

0
votes

I suffered the same issue. It was caused by the semi-colon of some environment variables.

If you are in Windows, first try to using the command SET, it will list out all your environment variables.

C:\Users>SET

Then, try to check all the variables carefully to see is there any semi-colon at the end of any variables. If there is any, delete the semi-colon.

In my case, previous

ComSpec=C:\windows\system32\cmd.exe;

So I delete the semi-colon of ComSpec and it fixed the issue.

0
votes

For me also worked deleting ; from ComSpec environment variable.

0
votes

I have the same issue npm “prefix -g is not recognized as an internal or external command” on window 8.It takes approx half of the day to solve.

Actual problem is window Environment variable path.

Here are the some steps that I follow to solve the problem.

1: Firslty, I remove node and npm default path setup by the node while installation .
Example: *C:\Program Files\nodejs;* *C:\Users\{pcName}\AppData\Roaming\npm*
if node path is exist both:path and PATH variable remove the node and npm path.

2: Check the Every environment variable if anyone having npm or node path remove the node and npm path.
In my case: ComSpec= having some path of nodejs
expample: ComSpec=C:\Users\{pcName}\AppData\Roaming\npm\node_modules\angularCli****
I replaced the value of ComSpec=C:\windows\system32\cmd.exe (without semicolon)

3: Add both nodejs and npm path in only system path or both path and PATH(if exist) variable:

path=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files\nodejs;C:\Users\{userName}\AppData\Roaming\npm```