'npm'不被识别为内部或外部命令,可操作程序或批处理文件 [英] 'npm' is not recognized as internal or external command, operable program or batch file
问题描述
我对Node.js完全陌生.我试图让Node.js在Windows 2008机器上工作,以便安装Karma,我将使用它来TDDing我的AngularJs代码.到目前为止,我已经完成了以下步骤
I am completely new to nodejs. I am trying to get nodejs to work on my Windows 2008 box in order to install Karma which I would use for TDDing my AngularJs code. I have done the following steps so far
- 无法识别使用Chocolatey ==> npm安装
- 无法识别使用来自nodejs.org ==> npm的64位nodejs安装程序进行安装
- 在此阶段,运行
where npm
会给我c:\User\<Username>\AppData\Roaming\npm
里面没有任何东西 - 我发现
C:\Program Files\nodejs
中安装了nodejs.在此目录中打开命令提示符可使npm
正常工作. - 所以我在
PATH
中添加了C:\Program Files\nodejs
,只是再次得到与npm is not recognized
相同的错误.
- nodejs存储库上的github问题之一说,我需要重新启动机器,然后它才能修复.但这到目前为止没有帮助
- 我确实在我的
Start -> Programms
菜单中看到一个Node.js
图标,该图标将我带到nodejs控制台,但不确定如何处理.
- Install using Chocolatey ==> npm is not recognised
- Install using 64-bit nodejs installer from nodejs.org ==> npm is not recognised
- At this stage, running
where npm
gives mec:\User\<Username>\AppData\Roaming\npm
which has nothing in it - I figure out that nodejs is installed in
C:\Program Files\nodejs
. Opening a command prompt in this directory makesnpm
work fine. - So I added
C:\Program Files\nodejs
toPATH
only to get the same error again thatnpm is not recognized
- One of the github issues on nodejs repository says that I need to restart the machine and it would fix. But that has not helped so far
- I do see a
Node.js
icon in myStart -> Programms
mennu which takes me to nodejs console but not sure what to do with that.
我错过了过程中的任何重要步骤吗?
Have I missed any important step in the process?
我发现,如果我从程序文件中打开"Nodejs命令提示符",则可以识别npm.如何使其在正常的命令提示符下工作?
I figured out that if I open "Nodejs command prompt" from program files, then npm is recognized. How do I make it work on a normal command prompt?
在node
之后,我开始遇到另一个应用程序的类似问题.我发布了这个问题在超级用户上使用a>并正确地指出了已接受的答案,我在PATH
中有一个附加的引用,这导致在引用之后添加的所有路径均出现问题.我感觉有些Chocolatey安装程序添加了此令人不安的报价,但我不确定是哪一个.
After node
I started facing a similar problem with another application. I posted this question on superuser and as rightly pointed out by the accepted answer, I had an additional quote in my PATH
which was causing issues with all the paths added after the quote. I have a feeling that some Chocolatey install adds this troubling quote but I am just not sure which one.
推荐答案
只需添加:
;C:\Program Files\nodejs\
在系统属性的环境变量的用户变量" 部分的 Path 变量的末尾.
To the end of your Path variable on the "User variable" section of the Environment Variables on the System Properties.
然后,重新打开命令提示符并键入
After that, reopen your command prompt and type
npm
这应该有效.
这篇关于'npm'不被识别为内部或外部命令,可操作程序或批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!