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.
How do I make pm2 auto-reload the project when a file is changed?
By default, pm2 doesn’t automatically refresh our server every time we change files. You need to start your pm2 project with the --watch cli argument in order to tell pm2 to refresh when files have changed:
pm2 start id_project --watch
check out the docs for more details, or @rogier-spieker answer which is more detailed.