"breakpoint set but not yet bound"调试时出错node.js
"breakpoint set but not yet bound" error when debugging node.js
我已经使用 link 中的配方配置了我的 Visual studio 代码来调试 nodejs,chrome(vuejs) 应用程序。但是,当我在 visual studio 代码中调试 "Meteor All" 错误时,我收到了 "Failed to exec debug script" 错误。
如果我在服务器端代码中添加断点,我会看到 "breakpoint set but not yet bound"。但是,我能够正确调试客户端代码。
我错过了什么?
Launch.json 在 visual studio 代码中:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Meteor: Chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}",
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"name": "Meteor: Node",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "debug"],
"outputCapture": "std",
"port": 9229,
"timeout": 30000
}
],
"compounds": [
{
"name": "Meteor: All",
"configurations": ["Meteor: Node", "Meteor: Chrome"]
}
]
}
登录Visual Studio代码:
C:\Program Files\nodejs\npm.cmd run debug
> vue-meteor-demo@ debug c:\temp\vuemeteor2
> meteor run meteor --settings settings.json --inspect-brk=9229
Unknown run target: meteor
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-meteor-demo@ debug: `meteor run meteor --settings settings.json --inspect-brk=9229`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-meteor-demo@ debug script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\AjitGoel\AppData\Roaming\npm-cache\_logs19-11-14T14_17_23_502Z-debug.log
debug.log:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'debug' ]
2 info using npm@6.4.1
3 info using node@v10.15.0
4 verbose run-script [ 'predebug', 'debug', 'postdebug' ]
5 info lifecycle vue-meteor-demo@~predebug: vue-meteor-demo@
6 info lifecycle vue-meteor-demo@~debug: vue-meteor-demo@
7 verbose lifecycle vue-meteor-demo@~debug: unsafe-perm in lifecycle true
8 verbose lifecycle vue-meteor-demo@~debug: PATH: <Path>
9 verbose lifecycle vue-meteor-demo@~debug: CWD: c:\temp\vuemeteor2
10 silly lifecycle vue-meteor-demo@~debug: Args: [ '/d /s /c',
10 silly lifecycle 'meteor run meteor --settings settings.json --inspect-brk=9229' ]
11 silly lifecycle vue-meteor-demo@~debug: Returned: code: 1 signal: null
12 info lifecycle vue-meteor-demo@~debug: Failed to exec debug script
13 verbose stack Error: vue-meteor-demo@ debug: `meteor run meteor --settings settings.json --inspect-brk=9229`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:182:13)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:182:13)
13 verbose stack at maybeClose (internal/child_process.js:962:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
14 verbose pkgid vue-meteor-demo@
15 verbose cwd c:\temp\vuemeteor2
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "debug"
18 verbose node v10.15.0
19 verbose npm v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error vue-meteor-demo@ debug: `meteor run meteor --settings settings.json --inspect-brk=9229`
22 error Exit status 1
23 error Failed at the vue-meteor-demo@ debug script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
我只用--inspect
,效果很好。
我没有成功指定 --inspect-brk=9229
的端口
--inspect
无论如何都使用端口 9229
你的服务器配置应该是这样的:
{
"type": "node",
"request": "attach",
"name": "server",
"restart": true,
"port": 9229
},
restart
选项在您编辑代码时很有用,因为它在服务器重启后仍然存在(通过重新附加)
如果调试器无法通过调试器附加到的节点进程 "reach" 断点文件,似乎会显示此消息。
VS Code 文档中没有很好地涵盖错误消息,因此很难找出导致错误的原因。
我通过向项目添加一个文件,在其中放置一个断点而不是在任何地方 include
/require
来测试它。当您 运行 调试器(在另一个文件上)时,您刚刚添加的断点将是 "set but not yet bound"。
相反,如果您 include
/require
新文件,断点将是正常的(即使您的测试从未到达断点所在的行)。
就我而言,我继承了一个代码库,发现如果您的脚本生成子进程(例如通过 child_process.execFile),调试器将不会跟踪子进程中的代码。相反,它会将断点显示为 "breakpoint set but not yet bound"。
我已经使用 link 中的配方配置了我的 Visual studio 代码来调试 nodejs,chrome(vuejs) 应用程序。但是,当我在 visual studio 代码中调试 "Meteor All" 错误时,我收到了 "Failed to exec debug script" 错误。 如果我在服务器端代码中添加断点,我会看到 "breakpoint set but not yet bound"。但是,我能够正确调试客户端代码。 我错过了什么?
Launch.json 在 visual studio 代码中:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Meteor: Chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}",
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"name": "Meteor: Node",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "debug"],
"outputCapture": "std",
"port": 9229,
"timeout": 30000
}
],
"compounds": [
{
"name": "Meteor: All",
"configurations": ["Meteor: Node", "Meteor: Chrome"]
}
]
}
登录Visual Studio代码:
C:\Program Files\nodejs\npm.cmd run debug
> vue-meteor-demo@ debug c:\temp\vuemeteor2
> meteor run meteor --settings settings.json --inspect-brk=9229
Unknown run target: meteor
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-meteor-demo@ debug: `meteor run meteor --settings settings.json --inspect-brk=9229`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-meteor-demo@ debug script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\AjitGoel\AppData\Roaming\npm-cache\_logs19-11-14T14_17_23_502Z-debug.log
debug.log:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'debug' ]
2 info using npm@6.4.1
3 info using node@v10.15.0
4 verbose run-script [ 'predebug', 'debug', 'postdebug' ]
5 info lifecycle vue-meteor-demo@~predebug: vue-meteor-demo@
6 info lifecycle vue-meteor-demo@~debug: vue-meteor-demo@
7 verbose lifecycle vue-meteor-demo@~debug: unsafe-perm in lifecycle true
8 verbose lifecycle vue-meteor-demo@~debug: PATH: <Path>
9 verbose lifecycle vue-meteor-demo@~debug: CWD: c:\temp\vuemeteor2
10 silly lifecycle vue-meteor-demo@~debug: Args: [ '/d /s /c',
10 silly lifecycle 'meteor run meteor --settings settings.json --inspect-brk=9229' ]
11 silly lifecycle vue-meteor-demo@~debug: Returned: code: 1 signal: null
12 info lifecycle vue-meteor-demo@~debug: Failed to exec debug script
13 verbose stack Error: vue-meteor-demo@ debug: `meteor run meteor --settings settings.json --inspect-brk=9229`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:182:13)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:182:13)
13 verbose stack at maybeClose (internal/child_process.js:962:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
14 verbose pkgid vue-meteor-demo@
15 verbose cwd c:\temp\vuemeteor2
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "debug"
18 verbose node v10.15.0
19 verbose npm v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error vue-meteor-demo@ debug: `meteor run meteor --settings settings.json --inspect-brk=9229`
22 error Exit status 1
23 error Failed at the vue-meteor-demo@ debug script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
我只用--inspect
,效果很好。
我没有成功指定 --inspect-brk=9229
--inspect
无论如何都使用端口 9229
你的服务器配置应该是这样的:
{
"type": "node",
"request": "attach",
"name": "server",
"restart": true,
"port": 9229
},
restart
选项在您编辑代码时很有用,因为它在服务器重启后仍然存在(通过重新附加)
如果调试器无法通过调试器附加到的节点进程 "reach" 断点文件,似乎会显示此消息。
VS Code 文档中没有很好地涵盖错误消息,因此很难找出导致错误的原因。
我通过向项目添加一个文件,在其中放置一个断点而不是在任何地方 include
/require
来测试它。当您 运行 调试器(在另一个文件上)时,您刚刚添加的断点将是 "set but not yet bound"。
相反,如果您 include
/require
新文件,断点将是正常的(即使您的测试从未到达断点所在的行)。
就我而言,我继承了一个代码库,发现如果您的脚本生成子进程(例如通过 child_process.execFile),调试器将不会跟踪子进程中的代码。相反,它会将断点显示为 "breakpoint set but not yet bound"。