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

前端 未结 5 806
南旧
南旧 2020-12-21 00:56

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

5条回答
  •  独厮守ぢ
    2020-12-21 01:42

    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.

提交回复
热议问题