gpt4 book ai didi

node.js - 如何让 VSCode 附加到 NPM 启动的 nodemon 上?

转载 作者:太空宇宙 更新时间:2023-11-03 23:55:05 29 4
gpt4 key购买 nike

我可以让 VSCode 使用 NPM 运行脚本启动我的应用程序,然后附加到生成的进程进行调试吗?

我的项目通过 NPM 脚本使用 nodemon 启动(以执行 babel 等)。但是,当应用程序启动时,VSCode 的调试器不会附加(跳过断点)。

//来自 package.json

"scripts": { "debug": "nodemon --inspect --exec babel-node src/app.js" }

//来自launch.json

    {
"type": "node",
"request": "launch",
"name": "Debug",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"debug"
],
"address": "localhost",
"port": 9229,
"protocol": "auto",
"restart": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"autoAttachChildProcesses": true
}

调试器似乎已启动,但我在几个测试调用旁边放置的断点被忽略。这是终端输出:

[nodemon] 1.19.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `babel-node --inspect src/app.js`
Debugger listening on ws://127.0.0.1:9229/13ef6ca8-40da-4741-854a-467e4230b2a7
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Hey!
Waiting for the debugger to disconnect...
[nodemon] clean exit - waiting for changes before restart```

最佳答案

看起来这是一个愚蠢的差事,因为从技术上讲这是不可能完成的。

关于node.js - 如何让 VSCode 附加到 NPM 启动的 nodemon 上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57610714/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com