\'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 com
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```