我使用以下方法制作了一个简单的 CRUD 应用程序
- 快车:4.13.4
- 吞咽:3.9.1
- 蒙戈数据库:v3.0.6
- 反应js:15.0.2。
- 节点:4.0.0
对于服务器端代码,我听说可以通过调试Visual Studio 代码 (v1.1.1.).
从 git bash 我通过以下方式启动应用程序gulp serve
.但我不知道如何开始调试!
我的 gulp 任务的一个片段。
gulp.task('serve',['bundle','start-server'],function(){
browserSync.init({
proxy:'http://localhost:3000',
port:9001
});
});
当我们单击 VS Code 上的调试按钮启动调试界面时,我们会看到一个 launch.json ,其中有两个配置选项。
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"preLaunchTask": null,
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"sourceMaps": false,
"outDir": null
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 3000,
"address": "localhost",
"restart": false,
"sourceMaps": false,
"outDir": null,
"localRoot": "${workspaceRoot}",
"remoteRoot": null
}
]
}
我猜这些是启动并附加配置。但是我们如何通过 debug 来实际启动 gulp。
我见过人们通过修改“program”键来启动 grunt 进程"program": "/usr/local/bin/grunt"
。但似乎我无法做到这一点
即使我通过 git bash 启动了我的应用程序并尝试按上述方式“附加”调试器here https://stackoverflow.com/questions/34652104/how-to-debug-express-js-server-code-on-node-using-visual-studio-code-by-attachin,vs code 只是显示一条错误消息,指出“已取消”!
TLDR;
- 当我们在 VS Code 中启动调试时,如何启动 gulp(或)grunt(或)启动服务器?
- 是否可以通过 cmd 或 bash 从外部启动应用程序,并且仍然能够使用调试器调试服务器端代码?如果是这样,launch.json 需要进行哪些更改?