我创建了一个VS代码扩展:
WSL workspaceFolder
,这将帮助您自动设置
remoteRoot
在你的启动.json到正确的WSL路径。例如我的
launch.json
,根据您的文件路径如下所示;
/vscode代码/启动.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to Remote",
"address": "localhost",
"port": 5858,
"localRoot": "${workspaceFolder}/web-frontend",
"remoteRoot": "${command:extension.vscode-wsl-workspaceFolder}/web-frontend"
}
]
}
然后要启动调试会话,在WSL终端中输入
NODE_ENV=debug node --nolazy --inspect-brk=5858
在要调试的脚本的路径之前。
Node.js releases