0

I installed node.js. When I tested it by running the command node -v it works fine. But when I try to run npm -v it gives me the following error:

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

Then after showing that error, it shows the version. It basically shows this error on all npm commands, including npm install commands. I have tried installing the same version on other machines and it works fine. However, the other machines are running Windows 10. Mine is running Windows 8.1.

EDIT: I have already tried uninstalling and reinstalling node, it didn't fix the issue.

Content of npm.cmd of Node.js v12.15.0:

:: Created by npm, please don't edit manually.
@ECHO OFF

SETLOCAL

SET "NODE_EXE=%~dp0\node.exe"
IF NOT EXIST "%NODE_EXE%" (
  SET "NODE_EXE=node"
)

SET "NPM_CLI_JS=%~dp0\node_modules\npm\bin\npm-cli.js"
FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_CLI_JS%" prefix -g') DO (
  SET "NPM_PREFIX_NPM_CLI_JS=%%F\node_modules\npm\bin\npm-cli.js"
)
IF EXIST "%NPM_PREFIX_NPM_CLI_JS%" (
  SET "NPM_CLI_JS=%NPM_PREFIX_NPM_CLI_JS%"
)

"%NODE_EXE%" "%NPM_CLI_JS%" %*
Mofi
  • 46,139
  • 17
  • 80
  • 143
Xavier Mukodi
  • 166
  • 1
  • 10
  • @Compo I didn't call an ```.exe``` file explicitly. I just typed ```npm -v``` and it printed that out. I even checked the *npm.cmd* file to make sense of the code inside, I don't seem to understand it. – Xavier Mukodi Feb 07 '20 at 11:47
  • 2
    Do either of these questions help? [1.](https://stackoverflow.com/q/51003183), [2.](https://stackoverflow.com/q/43312904). – Compo Feb 07 '20 at 11:57
  • the error message states that it can't find a command or file `CALL "C:\nodejs\\node.exe" "C:\nodejs\\node_modules\npm\bin\npm-cli.js" prefix -g` (yes, literally the whole string is considered a single command/filename. Check, where this line gets executed and show us the relevant code (I suspect there is some wrong quoting). `Npm` itself is innocent, `node.exe` doesn't even get executed. – Stephan Feb 07 '20 at 12:05
  • @Compo no they didn't help – Xavier Mukodi Feb 07 '20 at 12:50
  • @Stephan How do I check that? I'm guessing it's the file ```npm.cmd```, is that correct? – Xavier Mukodi Feb 07 '20 at 12:53
  • what happens when you run `where node` from `cmd`? – Gerhard Feb 07 '20 at 13:11

0 Answers0