在系统的 命令行提示符 执行 node -vnpm -v 都正常,但是在 Visual Studio Code 的终端(默认是 cmd)执行总是提示

'node' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

终端改成 PowerShell 则提示

node : 无法将“node”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
所在位置 行:1 字符: 1
+ node -v
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (node:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

总之就是提示找不到 node 和 npm 命令。

网上搜索了下,解决方法为更改 Code.exe 的兼容性,以管理员身价运行,重新启动 vscode 。
Snipaste_2020-01-10_09-44-27.png

参考链接:https://blog.csdn.net/jiangwei1994/article/details/81771963

标签: Node.js, vscode