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

时间:2017-02-27 08:56:09

标签: node.js visual-studio-code

我正试图在vscode中从调试器运行节点命令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).

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

1 个答案:

答案 0 :(得分:0)

我最终将"port"标记添加到"configurations"
--debug-brk节点命令的"build:live"参数。

最终配置:

"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"
}