VSCode编辑器 – 更改文件时重新启动NodeJs服务器

我正在使用Visual Studio Code作为NodeJS项目的编辑器。

目前我需要手动重新启动服务器,当我更改我的项目中的文件。

VSCode中是否有任何插件或configuration更改,当我在文件中进行更改时,可以自动重新启动NodeJS服务器。

您现在可以使用VS Code的Nodemon来实现这一点。 我今天testing了对VS Code的Nodemon支持,对我来说效果很好。 以下是我的VS代码细节。

  • 版本:1.9.1
  • 提交:f9d0c687ff2ea7aabd85fb9a43129117c0ecf519
  • date:2017-02-09T00:26:45.394Z
  • shell:1.4.6
  • 渲染器:53.0.2785.143
  • 节点:6.5.0

我在全局安装了Nodemon npm install -g nodemon并创build了VS Code启动configuration,如下所示

  { "name": "Nodemon Launch Server", "type": "node", "request": "launch", "cwd": "${workspaceRoot}", "runtimeExecutable": "nodemon", "runtimeArgs": [ "--debug=5858" ], "program": "${workspaceRoot}/server.js", "restart": true, "port": 5858, "console": "integratedTerminal", "internalConsoleOptions": "neverOpen" } 

参考: https : //code.visualstudio.com/docs/editor/node-debugging#_restarting-debug-sessions-automatically-when-source-is-edited

使用pm2来观看你的代码并自动重启

 npm install pm2 -g npm install pm2 

process.json

 { name : "App", script : "app.js", watch : true, } 

你可以find演示@ https://github.com/sivasankars/jade-title-rendering