Node - restart the server after editing certain files

I would like to automatically restart the server after editing certain files. Is there anything I can install to help me do this? - or I will need to make sure that the folder runs the script accordingly. Any pointers appreciated

+4
source share
4 answers

You can use Nodemon for this, there is even a video tutorial on this .

0
source

Use a supervisor . Install it using npm install supervisor -g and run your code using supervisor server.js and you should be good to go. Please note that by default it keeps track of files located in the same directory as server.js and its subdirectories, but it should be possible to add additional paths.

+7
source

https://github.com/mdlawson/piping is also good.

There are already node "wrappers" that handle viewing the change file and restarting the application (for example, node -supervisor), as well as rebooting during a crash, but I did not like this. edging adds hot reload functionality to the node, looking at your entire project files and reloading when something changes without requiring a wrapper.

0
source

Nodemon is good for it https://github.com/remy/nodemon In addition, if you want nodemon to restart your application only if certain files have been modified, it is important to have a .nodemonignore file in which you can specify which files should be ignore nodemon. Example .nodemonignore file:

/ public / * # ignore all public resources

/.* # any hidden (dot) files

*. md # markup files

*. css # CSS Files

.build / * # Create a folder

/Journal/*

0
source

Source: https://habr.com/ru/post/1380544/


All Articles