术语“节点”未被识别为 cmdlet、函数、脚本文件或可运行程序的名称

Suj*_*tYT 7 node.js visual-studio-code

在我的 VS Code 终端中运行 node 时出现此错误,除了我尝试在 CMD 中运行相同的东西并且它在那里工作但不在 VS Code 终端中: 在此处输入图片说明

node: The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

At line:1 char:1
+ node
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (node:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)

小智 23

对我有用的是:打开 Visual Studio Code -> 终端 -> 新终端

我尝试过的其他一切都没有...


小智 9

我也遇到了这个错误,我通过以管理员权限打开 Visual Studio Code 来解决它(在 Windows 中)。

演示


小智 9

尝试关闭然后重新打开 VS Code。

如果您在 VS Code 打开时安装了节点,则对 PATH 的更改尚不可见。(确保在安装节点时选择了添加到 PATH 选项...如果不确定将其添加到 PATH)

  • 这也对我有帮助,谢谢。我打开了多个 Visual Studio Code 窗口,我需要关闭所有窗口。 (3认同)