作为一个相当新的Apostrophe开发人员,而不是节点专家,我能够通过使用--inspect-brk
参数启动nodemon来成功调试Apostrophe。但是,我尝试通过启动apostrophe-monitor
模块来进行调试,但无济于事。
[编辑2019-01-18] :“无法调试”是指调试器未正确连接到进程,并且断点不起作用。 [/ edit]
尽管我能够运行它,并且通常我可以体验到更快的重新加载时间,但是刷新浏览器后出现很多错误(30%?)的次数非常多,我需要重新启动撇号监控器:
Waiting for changes...
MongoError: Topology was destroyed
at nextFunction (C:\Repo\apostrophe\monitor-test\node_modules\mongodb-core\lib\cursor.js:547:27)
at Cursor.next [as _next] (C:\Repo\apostrophe\monitor-test\node_modules\mongodb-core\lib\cursor.js:701:3)
at nextObject (C:\Repo\apostrophe\monitor-test\node_modules\mongodb\lib\cursor.js:680:8)
at Cursor.next (C:\Repo\apostrophe\monitor-test\node_modules\mongodb\lib\cursor.js:270:12)
at findOne (C:\Repo\apostrophe\monitor-test\node_modules\mongodb\lib\collection.js:1414:10)
at Collection.findOne (C:\Repo\apostrophe\monitor-test\node_modules\mongodb\lib\collection.js:1400:44)
at Collection.tryCatcher (C:\Repo\apostrophe\monitor-test\node_modules\bluebird\js\release\util.js:16:23)
at Collection.ret [as findOneAsync] (eval at makeNodePromisifiedEval (C:\Repo\apostrophe\monitor-test\node_modules\bluebird\js\release\promisify.js:184:12), <anonymous>:14:23)
这只是一个空的脚手架项目,具有以下配置:
package.json:
...
"main": "app.js,
"scripts": {
"start": "node app.js",
"debug": "nodemon --inspect-brk app.js",
"monitor": "monitor --inspect-brk"
},
...
app.js:
module.exports = require('apostrophe')({
root: module,
shortName: 'monitor-test',
modules : {
...
}
});
VS Code launch.json:
...
{
"type": "node",
"request": "launch",
"name": "Nodemon",
"runtimeExecutable": "nodemon",
"program": "${workspaceRoot}/app.js",
"restart": true,
//"console": "integratedTerminal",
"useWSL": true,
"args": ["--inspect-brk"],
"internalConsoleOptions": "openOnSessionStart"
},{
"type": "node",
"request": "attach",
"name": "Attach to node",
"processId": "${command:PickProcess}",
"restart": true,
"protocol": "inspector"
}
...
然后我用npm run monitor
运行它
有想法吗?