关于如何使用VS Code调试ExpressJS应用程序,有零篇好的著作。
我想做的是nodemon index.js
我的快速应用程序。然后在VS Code开放式Chrome的index.js
文件中设置我的断点,导航到https://myapp:4000
并期望我的断点被击中。
这是到目前为止我在launch.json
中尝试过的一切。
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/server/express-api/index.js",
"stopOnEntry": true,
"args": [],
"cwd": "${workspaceFolder}",
"preLaunchTask": null,
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"console": "internalConsole",
"sourceMaps": false
},
{
"type": "chrome",
"request": "attach",
"name": "Attach to Chrome",
"url": "https://myapp",
"port": 4000,
"webRoot": "${workspaceFolder}"
}
和
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"protocol": "inspector",
"runtimeExecutable": "nodemon",
"runtimeArgs": [
"--inspect=4000"
],
"program": "${workspaceFolder}/server/express-api/index.js",
"port": 4000,
"restart": true,
"env": {
"NODE_ENV": "development"
},
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"type": "chrome",
"request": "attach",
"name": "Launch Chrome",
"port": 9222,
"url": "ws://127.0.0.1:4000",
"webRoot": "${workspaceFolder}/server/express-api/index.js"
}
我的目录结构是这样的
${workspaceFolder}/client/ <-- angular app created with angular-cli
${workspaceFolder}/server/express-api/ <-- holds the index.js and all the route files
我的express api提供了我的angular-cli构建文件。 而我的express api已被提供
const app = express();
const https = require('https');
const httpsServer = https.createServer(credentials, app);
httpsServer.listen(4000, 'myapp', () => console.log('app running');
我在做什么错了?