'npm'不被识别为内部或外部命令,可操作程序或批处理文件 [英] 'npm' is not recognized as internal or external command, operable program or batch file

查看:1374
本文介绍了'npm'不被识别为内部或外部命令,可操作程序或批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对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

  1. 无法识别使用Chocolatey ==> npm安装
  2. 无法识别使用来自nodejs.org ==> npm的64位nodejs安装程序进行安装
  3. 在此阶段,运行where npm会给我c:\User\<Username>\AppData\Roaming\npm里面没有任何东西
  4. 我发现C:\Program Files\nodejs中安装了nodejs.在此目录中打开命令提示符可使npm正常工作.
  5. 所以我在PATH中添加了C:\Program Files\nodejs,只是再次得到与npm is not recognized
  6. 相同的错误.
  7. nodejs存储库上的github问题之一说,我需要重新启动机器,然后它才能修复.但这到目前为止没有帮助
  8. 我确实在我的Start -> Programms菜单中看到一个Node.js图标,该图标将我带到nodejs控制台,但不确定如何处理.
  1. Install using Chocolatey ==> npm is not recognised
  2. Install using 64-bit nodejs installer from nodejs.org ==> npm is not recognised
  3. At this stage, running where npm gives me c:\User\<Username>\AppData\Roaming\npm which has nothing in it
  4. I figure out that nodejs is installed in C:\Program Files\nodejs. Opening a command prompt in this directory makes npm work fine.
  5. So I added C:\Program Files\nodejs to PATH only to get the same error again that npm is not recognized
  6. 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
  7. I do see a Node.js icon in my Start -> 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之后,我开始遇到另一个应用程序的类似问题.我发布了这个问题并正确地指出了已接受的答案,我在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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆