vscode是比较不错的JS开发工具。nodemon可以实现修改JS代码后的自动重启server,不需要手动在去重启server。
1,安装nodemon
# npm install -g nodemon
2,创建测试项目
# express --view=ejs mytest # cd mytest # npm install
3,修改package.json
"scripts": {
"start": "node ./bin/www",
"debug": "nodemon --inspect-brk ./bin/www"
},
4,修改.vscode/launch.json
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch via NPM",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script", "debug"
],
"port": 9229
}
]
}
5,在routes/index.js打断点
6,浏览器访问网站,vscode的终端,调试控制台就有断点的内容了
转载请注明
作者:海底苍鹰
地址:http://blog.51yip.com/jsjquery/1963.html
