开发node应用每次修改都要重启?
nodemon 了解一下
# 文件保存就自动重启
nodemon app.js
使用多个调试方案
一般我用VScode 调试代码的时候,在launch.json
只有一下配置
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/app.js" // node app.js 这里也可以缓存别的文件
}
我们其实可以添加其他配置,比如直接调试当前文件
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/app.js"
},
{
"type": "node",
"request": "launch",
"name": "当前文件",
"program": "${file}"
}
这样我们在debug模式就有两个可选择的方案了
既能自动重启又能debug?
yes, vscode can,再添加以下配置
{
"type": "node",
"request": "launch",
"name": "nodemon",
"runtimeExecutable": "nodemon",
"program": "${workspaceFolder}/app.js",
"restart": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},