gpt4 book ai didi

node.js - 运行配置 - 无法连接到运行时进程

转载 作者:太空宇宙 更新时间:2023-11-04 02:10:28 25 4
gpt4 key购买 nike

我正在尝试从 vscode 中的调试器运行 Node 命令 npm run dev

我在 launch.json 中的运行配置:

"configurations": [{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run",
"dev"
],
"cwd": "${workspaceRoot}"
}]

我的脚本在package.json中:

"scripts": {
"dev": "npm run build:live",
"build:live": "nodemon --exec ./node_modules/.bin/ts-node -- ./app/*.ts"
}

但是当我运行配置时,我得到以下输出:

npm --debug-brk=18538 run dev 
> discordbot@1.0.0 dev /home/olian04/Documents/Projects/Node/JavaScript/DiscordBot.js
> npm run build:live
> discordbot@1.0.0 build:live /home/olian04/Documents/Projects/Node/JavaScript/DiscordBot.js
> nodemon --exec ./node_modules/.bin/ts-node -- ./app/*.ts
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `./node_modules/.bin/ts-node ./app/index.ts`

然后出现这个错误:

Cannot connect to runtime process (timeout after 10000 ms).

对我来说,它看起来好像有效,但它仍然抛出错误,并且代码在错误时停止运行,为什么?

最佳答案

我最终将“port”标签添加到“configurations”中。
以及 "build:live" Node 命令的 --debug-brk 参数。

最终配置:

"configurations": [{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run",
"dev"
],
"port": 5858,
"cwd": "${workspaceRoot}"
}]

最终脚本:

"scripts": {
"dev": "npm run build:live",
"build:live": "nodemon --debug-brk=5858 --exec ./node_modules/.bin/ts-node -- ./app/*.ts"
}

关于node.js - 运行配置 - 无法连接到运行时进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42481408/

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