我一整天都在尝试解决这个问题。
当我在 cmd 提示符下运行 node -v
或 npm install
时,它工作得非常好。但是当我在 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
我尝试卸载节点 js 并重新安装它。在环境变量(系统变量)中添加了节点js路径 C:\Program Files (x86)\nodejs\
。重新启动计算机。但似乎没有任何效果。请让我知道,我在这里缺少什么。
原文由 Anubhav Trivedi 发布,翻译遵循 CC BY-SA 4.0 许可协议
As dan-gph mentioned check the
Path
in environment variable using script$env:path -split ';' | Select-String nodejs
and once you update thePath
in environment variable, make sure to restartpowershell
并重新启动explorer.exe
。这将解决问题。如果您仍然遇到问题,请检查您安装了哪个 nodejs(32 位或 64 位)。仅安装 32 位,因为 powershell 或 cmd 是 32 位程序