node.js 节点未被识别为内部或外部命令,但在 PATH 中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26144724/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 17:56:37  来源:igfitidea点击:

node is not recognized as an internal or external command but is in PATH

node.js

提问by Mario Levrero

Although I've follow suggestions from:

虽然我遵循了以下建议:

I'm having an strange issue: Resume, although node path is list in Path, it doesn't find node.

我有一个奇怪的问题:继续,虽然节点路径在路径中列出,但它没有找到节点。

Workflow:

工作流程:

Microsoft Windows [Version 6.3.9600]    //Running CMD on windows 8.1 
(c) 2013 Microsoft Corporation. All rights reserved.

I followed suggestions in SO, adding variable to Environment Variables, and it's display Ok in Path:

我遵循了 SO 中的建议,将变量添加到环境变量中,并且在路径中显示为 Ok:

C:\Users\myUser>path
PATH=c:\Program Files (x86)\nodejs ; (...omitted...) //So folder is there

Next line will fail

下一行将失败

C:\Users\myUser>call jasmine-node spec  
'node' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\myUser>cd "c:\Program Files (x86)\nodejs" //So I move to the folder list before...

But if I move to folder list in Path, then it works OK.

但是如果我移动到路径中的文件夹列表,那么它就可以正常工作。

c:\Program Files (x86)\nodejs>call jasmine-node spec
>  (...omitted...) //Exec OK.

c:\Program Files (x86)\nodejs>node
>   //Exec OK. Waiting...

It seems contradictory.

好像很矛盾。

采纳答案by hobbs

The nodejs directory in your PATHisn't recognized because there's a space before the semicolon, so Windows is looking for a directory with a space at the end of the name, which doesn't exist.

PATH无法识别您中的 nodejs 目录,因为分号前有一个空格,因此 Windows 正在寻找名称末尾有空格的目录,该目录不存在。

回答by Gurupreet

Error: 'node' is not recognized as an internal or external command

错误:“节点”未被识别为内部或外部命令

The problem is may be the node is not installed on the machine in which the application is running.

问题可能是节点没有安装在运行应用程序的机器上。

Then install it and set the environment variable for nodejs.

然后安装它并为nodejs设置环境变量。

Or

或者

One more reason can be the nodejs path not set in the environment variable.

另一个原因可能是未在环境变量中设置 nodejs 路径。

Check with the following - open Control Panel -> System and Security -> System -> Advanced System Settings -> Environment Variables -> Path

检查以下内容 - 打开控制面板 -> 系统和安全 -> 系统 -> 高级系统设置 -> 环境变量 -> 路径

the nodejs path should be available here. If not available then add the following:

nodejs 路径应该在这里可用。如果不可用,则添加以下内容:

C:\Program Files (x86)\nodejs OR C:\Program Files\nodejs

C:\Program Files (x86)\nodejs 或 C:\Program Files\nodejs

Now Re-Run the application and the Error got resolved.

现在重新运行应用程序,错误得到解决。

回答by sudhAnsu63

Usually the environment variables are not effective till a system Restart.

通常环境变量在系统重启后才有效。

I suggest a System Restartfor all those who face the same issue when doing a clean install.

我建议System Restart所有在进行全新安装时遇到相同问题的人。

This worked for me.

这对我有用。

回答by bernaulli

;C:\Program Files\nodejs\

;C:\Program Files\nodejs\

Slash after \nodejs\ worked for me

\nodejs\ 对我来说有效后的斜线

回答by webmato

In Windows, you need to set node.js folder path into system variables or user variables.

在 Windows 中,您需要将 node.js 文件夹路径设置为系统变量或用户变量。

1) open Control Panel -> System and Security -> System -> Advanced System Settings -> Environment Variables

1)打开控制面板->系统和安全->系统->高级系统设置->环境变量

2) in "User variables" or "System variables" find variable PATHand add node.js folder path as value. Usually it is C:\Program Files\nodejs;. If variable doesn't exists, create it.

2) 在“用户变量”或“系统变量”中找到变量PATH并添加 node.js 文件夹路径作为值。通常是C:\Program Files\nodejs;。如果变量不存在,则创建它。

3) Restart your IDE or computer.

3) 重新启动您的 IDE 或计算机。

It is useful add also "npm" and "Git" paths as variable, separated by semicolon.

添加“npm”和“Git”路径作为变量很有用,用分号分隔。

回答by mscdex

If you did npm install jasmine-node -gyou should just need to do jasmine-node spec(no callprefix).

如果你这样做了,npm install jasmine-node -g你应该只需要做jasmine-node spec(没有call前缀)。

回答by Ahmad Baktash Hayeri

If you've checked your PATH, and are sure that the path for nodeis added properly, then you're likely to face the problem while running nodeOR npmcommands with CLI's other than the default command line interface of the operating system (e.g. Git bash in Windows).

如果您已经检查了您的PATH,并且确定node正确添加了 的路径,那么您在使用 CLI运行nodeORnpm命令时可能会遇到问题,而不是操作系统的默认命令行界面(例如 Windows 中的 Git bash) )。

The strange part is that you can check for node -vand npm -vin those CLIs, but for some reasons, they don't work well with those commands (especially when combined with installor update).

奇怪的是,您可以在这些 CLI 中检查node -vnpm -v,但由于某些原因,它们不能很好地与这些命令配合使用(尤其是与install或结合使用时update)。

Possible Solution

可能的解决方案

Try running nodewith the default terminal for your OS.

尝试node使用操作系统的默认终端运行。

回答by Bhanu Hoysala

I faced this issue even after adding node.exe to PATH. I wasn't able to run node command at random locations without running command prompt as administrator.

即使在将 node.exe 添加到 PATH 之后,我也遇到了这个问题。如果不以管理员身份运行命令提示符,我就无法在随机位置运行 node 命令。

Solution to this issue is, you have to give full access permissions to this node.exe file for different user types. open the properties of node.exe, go to security tabs, check all the security options to the user on your local machine.

此问题的解决方案是,您必须为不同的用户类型授予对该 node.exe 文件的完全访问权限。打开 node.exe 的属性,转到安全选项卡,检查本地计算机上用户的所有安全选项。

after doing this you should be able to access the node.exe file from any location.

执行此操作后,您应该能够从任何位置访问 node.exe 文件。

回答by Kuldeep Gangwar

things to check:

检查事项:

open CMD>Go to the directory where node.exe resides > type node -v > :

打开CMD>进入node.exe所在目录>输入node -v>:

  1. if it shows the version: Please add the same path (like> PATH=C:\Programfiles\nodejs\;) in the OS path in environment variable (any of the system or user variable, both work fine)

  2. if it doesn't recognize, please add a variable PATHEXT=.exe;in the environment variable (The PathExt is an Environment Variable that stores a list of the file extensions for the operation system to execute) and save them.

    Now open a new command prompt window and check.it must work.

  1. 如果它显示版本:请PATH=C:\Programfiles\nodejs\;在环境变量的操作系统路径中添加相同的路径(如> )(任何系统或用户变量,都可以正常工作)

  2. 如果它不识别,请PATHEXT=.exe;在环境变量中添加一个变量(PathExt是一个环境变量,存储操作系统执行的文件扩展名列表)并保存它们。

    现在打开一个新的命令提示符窗口并检查它必须工作。

回答by Sanchi Tyagi

The error:

错误:

node-is-not-recognized-as-an-internal-or-external-command

节点未被识别为内部或外部命令

And the following solution:

以及以下解决方案:

  1. Set Environment variable NODE_HOMEas C:\Program Files\nodejs
  2. Open cmd window and run:
  1. 将环境变量设置NODE_HOMEC:\Program Files\nodejs
  2. 打开cmd窗口并运行:
cd "C:\Program Files\nodejs"
npm install connect
npm install -g appium