[英]Error while running npm "prefix -g is not recognized as an internal or external command"
'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. 'CALL "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" 前缀 -g' 未被识别为内部或外部命令,可运行的程序或批处理文件。
I am using windows 8.1 enterprise version, and I have my files in appdata/npm still I am getting the above error.我正在使用 windows 8.1 企业版,并且我的文件位于 appdata/npm 中,但仍然出现上述错误。 I installed the latest node version,ie, v6.3.0 and I've even tried with the older version of node,ie, v4.4.7 and I am getting the same error.
我安装了最新的节点版本,即 v6.3.0,我什至尝试过使用旧版本的节点,即 v4.4.7,我得到了同样的错误。
I had the same issue.我有同样的问题。 Mine also printed this issue.
我的也打印了这个问题。
error file C:\\Windows\\system32\\cmd.exe;
错误文件 C:\\Windows\\system32\\cmd.exe;
seems I screwed up my comSpec in my environmental variables.似乎我在我的环境变量中搞砸了我的 comSpec。
The ";" “;” at the end of that line was causing the error.
在该行的末尾导致错误。
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.不确定是否仍然存在相同的问题,但最近我遇到了这个烦人的错误,并通过修改 nodejs 安装文件夹中的
npm.cmd
文件完成了解决。 It seems the error occurs because a wrong use of apostrophes and double quotes when calling the npm.cmd
file.错误似乎是因为在调用
npm.cmd
文件时错误使用了撇号和双引号。 By default the npm.cmd comes in this way:默认情况下, npm.cmd 以这种方式出现:
'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.这样 .cmd 必须正确执行,或者至少在 Windows 10 操作系统中对我有用。
Hope it helps.希望它有帮助。
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.如果你在 Windows 中,首先尝试使用命令 SET,它会列出你所有的环境变量。
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.所以我删除了 ComSpec 的分号并解决了这个问题。
For me also worked deleting ;
对我来说也删除了
;
from ComSpec environment variable.来自 ComSpec 环境变量。
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.我在窗口 8 上遇到了同样的问题 npm“prefix -g 未被识别为内部或外部命令”。解决它大约需要半天时间。
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 . 1:首先,我在安装时删除了节点和节点设置的 npm 默认路径。
Example : *C:\\Program Files\\nodejs;* *C:\\Users\\{pcName}\\AppData\\Roaming\\npm*
示例:
*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.如果节点路径同时存在:path 和 PATH 变量,则删除节点和 npm 路径。
2: Check the Every environment variable if anyone having npm or node path remove the node and npm path. 2:如果有人拥有 npm 或节点路径,请检查 Every 环境变量,删除节点和 npm 路径。
In my case: ComSpec= having some path of nodejs就我而言: ComSpec=有一些 nodejs 路径
expample: ComSpec=C:\\Users\\{pcName}\\AppData\\Roaming\\npm\\node_modules\\angularCli****
示例:
ComSpec=C:\\Users\\{pcName}\\AppData\\Roaming\\npm\\node_modules\\angularCli****
I replaced the value of ComSpec=C:\\windows\\system32\\cmd.exe
(without semicolon)我替换了
ComSpec=C:\\windows\\system32\\cmd.exe
(不带分号)
3: Add both nodejs and npm path in only system path or both path and PATH(if exist) variable: 3:仅在系统路径或路径和PATH(如果存在)变量中添加nodejs和npm路径:
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```
In my case I had a custom shell configured in the ComSpec
environment variable.就我而言,我在
ComSpec
环境变量中配置了一个自定义 shell。 Removing this fixed the problem.删除这个解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.