我以前使用gulp和运行gulp从Visual Studio Code debugger启动我的应用程序和侦听器,但最近需要切换到通过npm运行脚本。不幸的是,在VSCode中,我不能通过调试器运行npm脚本,所以我不得不求助于运行节点来直接启动我的服务器,这样就摆脱了自动重新加载代码的侦听器任务。
这看起来应该很简单,但到目前为止,我没有太多的运气。下面是我的launch.json文件中的一个片段,我试图使用它,但是找不到npm。
{
...
"program": "npm",
"args": [
"run",
"debug"
],
...
}
这给出了下面的错误。
错误请求'launch':程序'c:\myproject\npm‘不存在
相关资源:
发布于 2016-09-21 05:02:35
VS代码似乎将支持release from October 2016中的npm脚本和其他启动场景。
下面是一个proposed on GitHub的例子。
packages.json
"scripts": {
"debug": "node --nolazy --debug-brk=5858 myProgram.js"
},
vscode启动配置
{
"name": "Launch via NPM",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script", "debug"
],
"port": 5858
}
发布于 2016-04-06 12:55:18
{ "name":"Attach to npm","type":" node ","request":"attach","port":5858,"address":"localhost","restart":false,"sourceMaps":false,"outDir":null,"localRoot":"${workspaceRoot}","remoteRoot":null }
“脚本”:{ "start":"node app.js","debug":"node --debug-brk app.js“...
$npm运行调试
发布于 2021-08-27 12:23:59
现在,当你将鼠标悬停在package.json中的脚本名称上时,VS代码会给你一个“调试脚本”按钮。
https://stackoverflow.com/questions/34835082
复制相似问题