node.js “节点”未被识别为内部或外部命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8768549/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'node' is not recognized as an internal or external command
提问by sellarafaeli
I've been working with node.jsv0.6.3, locally installed on Windows Vistaat C:\Program Files\Nodejs. I recently upgraded to (by running the installer for) v0.6.6. It seemed like it worked for a while, but now if I try to run nodefrom any directory I get a
我一直在使用node.jsv0.6.3,本地安装在Windows Vista上C:\Program Files\Nodejs。我最近升级到(通过运行安装程序)v0.6.6。似乎它工作了一段时间,但是现在如果我尝试node从任何目录运行,我会得到一个
'node' is not recognized as an internal or external command
“节点”未被识别为内部或外部命令
message, though running nodefrom C:\Program Files\Nodejsdoeswork.
消息,虽然运行nodefromC:\Program Files\Nodejs确实有效。
I tried rebooting, removing node, reinstalling, reinstalling 0.6.3 - nothing seems to work. I just don't get why nodefails to recognize system path, though nodeworks from its base dir?
我尝试重新启动,删除节点,重新安装,重新安装 0.6.3 - 似乎没有任何效果。我只是不明白为什么node无法识别系统路径,尽管node可以从其基本目录运行?
回答by First Zero
Node is missing from the SYSTEM PATH, try this in your command line
系统路径中缺少节点,请在命令行中尝试此操作
SET PATH=C:\Program Files\Nodejs;%PATH%
and then try running node
然后尝试运行 node
To set this system wide you need to set in the system settings - cf - http://banagale.com/changing-your-system-path-in-windows-vista.htm
要设置此系统范围,您需要在系统设置中进行设置 - cf - http://banagale.com/changed-your-system-path-in-windows-vista.htm
To be very clean, create a new system variable NODEJS
为了非常干净,创建一个新的系统变量 NODEJS
NODEJS="C:\Program Files\Nodejs"
Then edit the PATHin system variables and add %NODEJS%
然后编辑PATH系统变量并添加%NODEJS%
PATH=%NODEJS%;...
回答by Varun Achar
Nodejs's installation adds nodejs to the path in the environment properties incorrectly.
Nodejs 的安装错误地将 nodejs 添加到环境属性中的路径。
By default it adds the following to the path:
默认情况下,它会将以下内容添加到路径中:
C:\Program Files\nodejs\
The ending \is unnecessary. Remove the \and everything will be beautiful again.
结局\是不必要的。删除\,一切都会再次美丽。
回答by alessioalex
Go to the folder in which you have Node and NPM (such as C:\Program Files (x86)\nodejs\) and type the following:
转到您拥有 Node 和 NPM 的文件夹(例如C:\Program Files (x86)\nodejs\)并键入以下内容:
> set path=%PATH%;%CD%
> setx path "%PATH%"
From http://www.hacksparrow.com/install-node-js-and-npm-on-windows.html
来自http://www.hacksparrow.com/install-node-js-and-npm-on-windows.html
回答by RandallTo
Everytime I install node.js it needs a reboot and then the path is recognized.
每次我安装 node.js 时,它都需要重新启动,然后才能识别路径。
回答by user1207577
Watch out for other paths ending in \ too. I had this:
注意其他以 \ 结尾的路径。我有这个:
...bin;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\nodejs\
and changed it to this:
并将其更改为:
bin;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\nodejs
removing the final \, but it still didn't work. The previous path, for the Web Platform Installer, had a trailing \ too. Removing that fixed the problem.
删除最后一个\,但它仍然不起作用。对于 Web 平台安装程序,先前的路径也有一个尾随 \。删除它解决了问题。
回答by Sandersjr2
Make sure nodejs in the PATH is in front of anything that uses node.
确保 PATH 中的 nodejs 在使用 node.js 的任何东西之前。
回答by pasx
I set the NODEJS variable in the system control panel but the only thing that worked to set the path was to do it from command line as administrator.
我在系统控制面板中设置了 NODEJS 变量,但设置路径的唯一方法是以管理员身份从命令行执行此操作。
SET PATH=%NODEJS%;%PATH%
设置路径=%NODEJS%;%PATH%
Another trick is that once you set the path you must close the console and open a new one for the new path to be taken into account.
另一个技巧是,一旦您设置了路径,您必须关闭控制台并打开一个新的控制台,以便将新路径考虑在内。
However for the regular user to be able to use node I had to run set path again not as admin and restart the computer
但是,为了让普通用户能够使用节点,我必须再次以管理员身份运行 set path 并重新启动计算机
回答by Gio Borje
Try adding C:\Program Files\Nodejsto your PATHenvironment variable. The PATHenvironment variable allows run executables or access files within the folders specified (separated by semicolons).
尝试添加C:\Program Files\Nodejs到您的PATH环境变量中。在PATH环境变量允许指定的文件夹(由分号分隔)内运行可执行文件或访问文件。
On the command prompt, the command would be set PATH=%PATH%;C:\Program Files\Nodejs.
在命令提示符下,命令将是set PATH=%PATH%;C:\Program Files\Nodejs.

