如何将实时重新加载添加到我的 nodejs 服务器

问题描述:

这是我如何运行我的服务器 nodejs.当我对前端开发中的代码进行更改时,我需要实时重新加载我的服务器

This is how can i run my server nodejs. I need to live reload my server when i make changes to the code in the front-end dev

"start": "node server.js"

第一:

npm install -g nodemon

下一步将脚本行添加到您的 package.json

next add a script line to your package.json

"live": "nodemon server.js" 

现在当你 npm live 它会实时重新加载

now when you npm live it'll live reload

有关详细信息,请参阅https://github.com/remy/nodemon

更新如果还需要重新加载实时页面

update if live page reload is also needed

npm install -g livereload
livereload . -w 1000 -d

更多详情请参见https://github.com/napcs/node-livereload