2017-02-27 1004 views
1

我試圖從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 
> [email protected] dev /home/olian04/Documents/Projects/Node/JavaScript/DiscordBot.js 
> npm run build:live 
> [email protected] 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). 

對我來說,它看起來好像工作,但它仍然會引發錯誤,並且代碼停止運行時,爲什麼?

回答

0

我最終將"port"標記添加到"configurations"
--debug-brk參數爲"build:live"節點命令。

最終CONFIGS:

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