為什麼我的egg-bin在Visual Studio Code中調試功能無法使用?

以下是我的項目的package.json:

{
"name": "wind.pevc.serv.master",
"version": "1.0.0",
"description": "",
"private": true,
"dependencies": {
"egg": "^1.8.0",
"egg-development-proxyworker": "^1.1.1",
"egg-mysql": "^3.0.0",
"egg-scripts": "^1.0.0",
"mocha": "^3.5.3"
},
"devDependencies": {
"autod": "^2.9.0",
"autod-egg": "^1.0.0",
"egg-bin": "^4.3.0",
"egg-ci": "^1.8.0",
"egg-cors": "^1.2.0",
"egg-mock": "^3.9.0",
"eslint": "^4.3.0",
"eslint-config-egg": "^5.0.0",
"webstorm-disable-index": "^1.2.0"
},
"engines": {
"node": ">=6.0.0"
},
"scripts": {
"start": "egg-scripts start --daemon",
"stop": "egg-scripts stop",
"dev": "egg-bin dev",
"debug": "egg-bin debug",
"test": "npm run lint -- --fix npm run test-local",
"test-local": "egg-bin test",
"cov": "egg-bin cov",
"lint": "eslint .",
"ci": "npm run lint npm run cov",
"autod": "autod"
},
"ci": {
"version": "6, 8"
},
"repository": {
"type": "git",
"url": ""
},
"author": "pevc",
"license": "MIT"
}

以及我的launch..json:

{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Egg",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "npm",
"windows": {
"runtimeExecutable": "npm.cmd"
},
"runtimeArgs": [
"run",
//"dev",
//"--",
"debug"
],
"protocol": "inspector",
"port": 5858
}
/*{
"type": "node",
"request": "attach",
"name": "Attach Agent",
"port": 5856,
"protocol": "legacy"
},
{
"type": "node",
"request": "attach",
"name": "Attach Worker",
"restart": true,
"port": 10086,
"protocol": "legacy"
}*/
],
"compounds": [{
"name": "Debug",
"configurations": ["Launch Egg"]
}]
}

在命令行中切換到本地目錄(項目目錄)運行以下程序正常:

1) npm run dev

2) npm run debug

我的VS Code是最新版的(1.16.0),NodeJS版本是v8.4.0。

點擊F5之後,彈出以下錯誤:

無法連接到運行中的進程,將在10000毫秒後超時 - (原因:無法連接到目標:connect ECONNREFUSED 127.0.0.1:5858)


你那個方式有點舊了,現在不再需要 egg-development-proxyworker 了,已經直接集成到 egg-bin debug 了,可以看下官方文檔:

Egg - 本地開發 - 使用 VSCode 進行調試eggjs.org圖標

或者直接使用 vscode 插件:

eggjs/vscode-eggjsgithub.com圖標


推薦閱讀:

追求技術之上的進階閱讀學習索引
Coding 如何使用 Coding 開發 Coding
《Software Design》 - 一本來自日本的軟體工程師雜誌

TAG:軟體開發 | VisualStudioCode | eggjs |