node.js 无法识别术语“节点”...在 Powershell 中

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

The term 'node' is not recognized... In Powershell

windowsnode.jspowershellnpm

提问by Anubhav Trivedi

I have been trying to resolve this issue for the whole day.

我一整天都在努力解决这个问题。

When I run node -vor npm installin cmd prompt, it works absolutely fine. But when I run the same commands in Powershell, it gives the following error:s

当我运行node -vnpm install在 cmd 提示符下时,它工作得非常好。但是当我在 Powershell 中运行相同的命令时,它给出了以下错误:s

PS C:\Users\Anubhav.Trivedi> node -v
The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelli
ng of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:5
+ node <<<<  -v
    + CategoryInfo          : ObjectNotFound: (node:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I tried uninstalling node js and reinstalling it. Added node js path C:\Program Files (x86)\nodejs\to enviroment variables (system variables). Restarting computer. But nothing seems to work. Kindly let me know, what am I missing here.

我尝试卸载 node js 并重新安装它。添加节点 js 路径C:\Program Files (x86)\nodejs\到环境变量(系统变量)。重新启动计算机。但似乎没有任何效果。请让我知道,我在这里错过了什么。

采纳答案by Anubhav Trivedi

As dan-gph mentioned check the Pathin environment variable using script $env:path -split ';' | Select-String nodejsand once you update the Pathin environment variable, make sure to restart powershelland also restart explorer.exe. This would resolve the issue.

正如 dan-gph 提到的Path,使用脚本检查in 环境变量$env:path -split ';' | Select-String nodejs,一旦更新Pathin 环境变量,请确保重新启动powershell并重新启动explorer.exe。这将解决问题。

If you still face issues, check which nodejs you have installed (32bit or 64bit). Install 32 bit only as powershell or cmd are 32bit programs

如果您仍然遇到问题,请检查您安装了哪个 nodejs(32 位或 64 位)。仅安装 32 位,因为 powershell 或 cmd 是 32 位程序

回答by Neel Patel

These issues cannot be installed from the Package Manager console, so I had to browse lot of things to fix the issues and finally I got the solution.

这些问题无法从包管理器控制台安装,所以我不得不浏览很多东西来解决问题,最后我得到了解决方案。

Maybe we followed these scenarios

也许我们遵循了这些场景

  • Missing Node.js software

  • Wrongly updated Windows environment path

  • Installed in the wrong path

  • Old version of Node.js software

  • 缺少 Node.js 软件

  • 错误更新的 Windows 环境路径

  • 安装在错误的路径

  • 旧版本的 Node.js 软件

You can download the latest Node.jssoftware here.

您可以在此处下载最新的Node.js软件。

Update Path

更新路径

After installation, automatically create nodejs folder in this path “C:\Program Files (x86)” or “C:\Program Files “.

安装完成后,自动在“C:\Program Files (x86)”或“C:\Program Files”这个路径下创建nodejs文件夹。

Open Control Panel -> User Accounts -> Change my environmental variable and verify the path Variable value “C:\Program Files (x86)\nodejs” or “C:\Program Files \nodejs “.

打开控制面板 -> 用户帐户 -> 更改我的环境变量并验证路径变量值“C:\Program Files (x86)\nodejs”或“C:\Program Files\nodejs”。

new => user = path => value = C:\Program Files (x86)\nodejs and after apply that.

new => user = path => value = C:\Program Files (x86)\nodejs 然后应用它。

and close Editor and restart it. it will work correctly.

并关闭编辑器并重新启动它。它会正常工作。

note:- enter your path instead of copy of this path.

注意:- 输入您的路径而不是此路径的副本。