當我在控制檯中鍵入npm run debug
時,得到:"Debugger listening on ws://127.0.0.1:3090/d17dfe56-4fa4-4686-a62e-d07cff78c834"
。當我用鉻版去這個地址時,我看到的唯一的東西是"WebSockets request was expected"
。我應該調整配置的哪些部分以使調試器工作?我正在使用最新版本的nodejs。無法爲具有babel節點的節點啓動VSCode調試器
的package.json腳本
"scripts": {
"prod": "webpack -p --env.production --progress",
"start": "babel-node --presets es2015 server/server.js",
"watch": "nodemon --exec npm run start",
"debug": "babel-node --presets es2015 server/server.js --inspect --debug-brk=3090"
}
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch via NPM",
"type": "node",
"request": "launch",
"runtimeExecutable": "npm",
"program": "${workspaceRoot}/server/server.js",
"restart": true,
"runtimeArgs": [
"run-script", "debug"
],
"port": 3090
},
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:3090",
"webRoot": "${workspaceRoot}"
},
{
"type": "chrome",
"request": "attach",
"name": "Attach to Chrome",
"port": 3090,
"webRoot": "${workspaceRoot}"
}
]
}
文件結構:
├───.vscode
├───js
├───server
│ ├───db
│ ├───middleware
│ ├───models
│ ├───server.js
謝謝。我安裝了6.2版本的節點js,現在我從控制檯獲取了一個正確的URL。但是,chrome開發工具中的「sources」中不存在server.js文件。我的launch.json有問題嗎? – Umbrella
考慮到您已經從工作空間位置運行您的項目,您可以嘗試更改'「程序」:「$ {workspaceRoot} /server/server.js」,使用'「program」:「$ {workspaceRoot}/server .js「,看看它是否在運行。 – Dhruvify
不幸的是,「$ {workspaceRoot} /server.js」和「$ {workspaceRoot}」都不起作用。 – Umbrella