【发布时间】:2017-10-11 04:54:04
【问题描述】:
我无法将调试器附加到已经运行的 NodeJS Web 应用程序。
以下是我的 VSCode 启动配置:
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 3001
},
我收到以下错误消息:
无法连接到运行时进程(原因:此套接字已被对方终止)。
现在,当我在上述配置中添加protocol : inspector 时,它会显示以下错误消息:
确保使用 --inspect 启动节点。无法连接到运行时进程,10000 毫秒后超时
我目前使用的是v8.6.0版本的NodeJS
以下是我在 package.json >> 脚本中的配置:
"scripts": {
"start": "npm run build && npm run watch --inspect",
"build": "npm run build-sass && npm run build-ts && npm run tslint && npm run copy-static-assets",
"serve": "nodemon dist/server.js",
"watch": "concurrently -k -p \"[{name}]\" -n \"Sass,TypeScript,Node\" -c \"yellow.bold,cyan.bold,green.bold\" \"npm run watch-sass\" \"npm run watch-ts\" \"npm run serve\"",
"test": "jest --forceExit",
"build-ts": "tsc",
"watch-ts": "tsc -w",
"build-sass": "node-sass src/public/css/main.scss dist/public/css/main.css",
"watch-sass": "node-sass -w src/public/css/main.scss dist/public/css/main.css",
"tslint": "tslint -c tslint.json -p tsconfig.json",
"copy-static-assets": "node copyStaticAssets.js",
"debug": "npm run build && npm run watch-debug",
"serve-debug": "nodemon --inspect dist/server.js",
"watch-debug": "concurrently -k -p \"[{name}]\" -n \"Sass,TypeScript,Node\" -c \"yellow.bold,cyan.bold,green.bold\" \"npm run watch-sass\" \"npm run watch-ts\" \"npm run serve-debug\""
},
【问题讨论】:
-
你是如何运行节点服务器的?
-
只需在 VS 终端中使用“npm start”命令
-
Ensure Node was launched with --inspect我认为您需要使用--inspect标志运行它。 -
能否分享完整的命令。此外,当尝试运行附加配置时,它会多次给出以下错误消息:[Node] GET /json 404 2.859 ms - 143
-
npm start --inspect?或者,node bin/www --inspect
标签: node.js debugging visual-studio-code