Nodemon All The Projects!

As time has marched on, I’ve noticed a couple different things I do repeatedly when starting a new node.js project. One is checking my npm version before I create the new project. The second is adding nodemon to the app immediately after I successfully run npm init. It’s a useful tool to always keep in your developer tool belt as you charge through your GIT commits!
What is Nodemon?
Nodemon is a package that watches for local development environment changes in your node.js project and when it sees one made, it restarts the local instance to pull in the changes automatically.
It was initially created by Remy Sharp, who’s based out of Brighton, UK where he runs his own business called Left Logic! The project is open source and has had 119 contributors on the github project to date.
What are all the benefits?
Remy and crew really did a great job of breaking down the full list of benefits of this tool on the Nodemon website which looks like:
- 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.
- Watches specific directories.
- Works with server applications or one time run utilities and REPLs.
How Do I Add It To My Node Project?
Adding nodemon to your project globally is as simple as:
npm install -g nodemonNow in your terminal you can run the command below to enjoy joys of auto refresh:
nodemon [Your APP]What’s That? You Rather Have It As A Dev Dependency?
You can include nodemon as a dev dependency as easy as pie:
npm install --save-dev nodemonHowever, keep in mind that you will need to run it through a npm script within your package.json. It may look like this:
"scripts": {
"startdev": "./node_modules/nodemon/bin/nodemon.js app.js"
}Which means to run the above script it would be:
npm run startdevThis will run nodemon from your packages in which you can see a confirmation populate in terminal that it’s running like below:
[nodemon] 1.18.3
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node app.js`Overall Thoughts
I’ve found time and time again nodemon brings value to my development experience and projects through saving me time, stopping and starting the project locally, as I work on crafting changes to the project. I highly recommend giving it a shot in your next or existing node app.
Also be sure to check out the Nodemon.io website and their documentation at their GitHub repo!
