WSL + VS Code:VSCode 假定 `node` 与 `nodejs` 二进制名称
WSL + VS Code: VSCode assumes `node` versus `nodejs` binary name
我的目标是使 Windows 10 + WSL 成为一个开发平台,用于执行 *IX 风格的编程,就像我过去几年在 OSX 上所拥有的一样好。我也在尝试新事物,包括这个新奇的 VS Code。
- 使用 WSL + Ubuntu 我安装了
nodejs
包。
- 我使用 JavaScript
在 VS Code 中创建了一个 "Hello World"
- 我运行调试命令
Cannot find runtime 'node' on PATH. Make sure to have 'node' installed.
嗯。好的。系统提示我打开 launch.json
或 close
。
所以我想到了一种变通方法,尝试将 node
的别名添加到 nodejs
。
我重新启动了 VS Code,尝试了同样的过程,同样的失败。
然后我尝试了 /usr/bin/node
到 /usr/bin/nodejs
之间的符号链接。同样的错误。
我认为这是 post-WSL 时代的一个非常标准的用例,但我没有找到规范的实现,也没有看到 "That's impossible!" 所以,我们在这里:)
我使用 nvm 在 Ubuntu 上安装 Node,但如果您正常安装它应该可以正常工作。
例如
nvm install 9.2.0
nvm alias default 9.2.0
If you want to run Node.js in the Linux subsystem on Windows (WSL), you can use the approach from above as well. However to make this even simpler, we've introduced a useWSL flag to automatically configure everything so that Node.js runs in the Linux subsystem and source is mapped to files in your workspace.
Here is the simplest debug configuration for debugging hello.js in WSL:
{
"type": "node",
"request": "launch",
"name": "Launch in WSL",
"useWSL": true,
"program": "${workspaceFolder}/hello.js"
}
以上对我不起作用,但这里的最佳答案对我有用:
https://askubuntu.com/questions/1065276/cannot-find-runtime-node-on-path-in-visual-studio-code-running-installed-on-u?newreg=dbdc6529203049dc9106b3b1aa6c84e6
简而言之,似乎有两个选择。
1 -(对我有用)在 VSCode 终端中使用 'which node
' 获取路径,然后将 "runtimeExecutable": "insert-path-you-got-here",
行添加到 launch.json
2 -(我还没有尝试过)在 ~/.profile 中添加 nvm 初始化脚本(请参阅 link 中的其他答案)。
我的目标是使 Windows 10 + WSL 成为一个开发平台,用于执行 *IX 风格的编程,就像我过去几年在 OSX 上所拥有的一样好。我也在尝试新事物,包括这个新奇的 VS Code。
- 使用 WSL + Ubuntu 我安装了
nodejs
包。 - 我使用 JavaScript 在 VS Code 中创建了一个 "Hello World"
- 我运行调试命令
Cannot find runtime 'node' on PATH. Make sure to have 'node' installed.
嗯。好的。系统提示我打开 launch.json
或 close
。
所以我想到了一种变通方法,尝试将 node
的别名添加到 nodejs
。
我重新启动了 VS Code,尝试了同样的过程,同样的失败。
然后我尝试了 /usr/bin/node
到 /usr/bin/nodejs
之间的符号链接。同样的错误。
我认为这是 post-WSL 时代的一个非常标准的用例,但我没有找到规范的实现,也没有看到 "That's impossible!" 所以,我们在这里:)
我使用 nvm 在 Ubuntu 上安装 Node,但如果您正常安装它应该可以正常工作。
例如
nvm install 9.2.0
nvm alias default 9.2.0
If you want to run Node.js in the Linux subsystem on Windows (WSL), you can use the approach from above as well. However to make this even simpler, we've introduced a useWSL flag to automatically configure everything so that Node.js runs in the Linux subsystem and source is mapped to files in your workspace.
Here is the simplest debug configuration for debugging hello.js in WSL:
{ "type": "node", "request": "launch", "name": "Launch in WSL", "useWSL": true, "program": "${workspaceFolder}/hello.js" }
以上对我不起作用,但这里的最佳答案对我有用: https://askubuntu.com/questions/1065276/cannot-find-runtime-node-on-path-in-visual-studio-code-running-installed-on-u?newreg=dbdc6529203049dc9106b3b1aa6c84e6
简而言之,似乎有两个选择。
1 -(对我有用)在 VSCode 终端中使用 'which node
' 获取路径,然后将 "runtimeExecutable": "insert-path-you-got-here",
行添加到 launch.json
2 -(我还没有尝试过)在 ~/.profile 中添加 nvm 初始化脚本(请参阅 link 中的其他答案)。