Nodemon – Automatic Restart the node application
What is Nodemon ?
Nodemon is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected.
nodemon does not require any additional changes to your code or method of development. nodemon is a replacement wrapper for
node, to use
nodemon replace the word
node on the command line when executing your script.
- Automatic restarting of application.
- Detects default file extension to monitor.
- Default support for node & coffeescript, but easy to run any executable (such as python, make, etc).
- Ignoring specific files or directories.
- Watch specific directories.
- Works with server applications or one time run utilities and REPLs.
- Requirable in node apps.
- Open source and available on github.
Either through cloning with git or by using npm (the recommended way):
npm install -g nodemon
Now will be installed globally to your system path.
You can also install as a development dependency:
npm install --save-dev nodemon
With a local installation, nodemontool will not be available in your system path. Instead, the local installation of nodemon can be run by calling it from within an npm script (such as
npm start) or using
nodemontool wraps your application, so you can pass all the arguments you would normally pass to your app:
nodemon [your node app]
For CLI options, use the
Using this tool is simple, if my application accepted a host and port as the arguments, I would start it as so:
nodemon ./server.js localhost 8080
Any output from this script is prefixed with
[nodemon], otherwise all output from your application, errors included, will be echoed out as expected.
If no script is given, nodemon will test for a
package.json file and if found, will run the file associated with the main property (ref).
You can also pass the
inspect flag to node through the command line as you would normally:
nodemon --inspect ./server.js 80
If you have a
package.json file for your app, you can omit the main script entirely and it will read the
package.json for the
main property and use that value as the app.
nodemon will also search for the
scripts.start property in
package.json (as of nodemon 1.1.x).
2 thoughts on “Nodemon – Automatic Restart the node application”
Pingback: How to Send e-mail using NodeJS - How To - IoTbyHVM
Pingback: How to Send e-mail using NodeJS - CoolDigiBytes