如何在使用pm2时自动重新加载Node.js项目 [英] How to automatically reload Node.js project when using pm2
本文介绍了如何在使用pm2时自动重新加载Node.js项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在使用Express.js编写Node.js,每当我更改文件路由器或应用程序中的一行代码时,我需要输入命令:
I am currently programming Node.js with Express.js, and every time I change a line of code in the file router or app, I need to type the command:
pm2 reload id_project.
当文件发生变化时,如何让pm2自动重新加载项目?
How do I make pm2 auto-reload the project when a file is changed?
推荐答案
默认情况下,每次更改文件时,节点都不会自动刷新我们的服务器。我不知道具体的pm2解决方案,但你可以用nodemon做到这一点。只需安装: npm install -g nodemon
并使用: nodemon server.js
。
By default, node doesn’t automatically refresh our server every time we change files. I don't know about specific pm2 solution, but you can do that with nodemon. Just install with: npm install -g nodemon
and use with: nodemon server.js
.
这篇关于如何在使用pm2时自动重新加载Node.js项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文