klequis' blog

This chapter/section is part of a future book on full-stack MERN (MongoDB, Express, React & Node) development. For the full table of contents with links to all completed chapters see Full-stack Mern Development.

Installing Nodemon on Ubuntu

October 30, 2019

nodemon is a simple process that will restart your development server when files it is watching have changed.

You can use nodemon just like node. For example, if you had a file named demo-code.js with this code:

console.log('hello from demo code')

You can run it using node with this command:

node demo-code.js

‘hello from demo code’ will be printed to the console. After each code change you need to re-issue the above command.

To run the code with nodemon:

nodemon demo-code.js

Now when you change and save your code it will re-run automatically.

Installation

Use this command to install nodemon:

sudo npm i -g nodemon

Give it a try

mkdir nodemon-try
cd nodemon-try
touch demo-code.js

Add some code to demo-code.js:

console.log('hello')

Then run the code using nodemon:

nodemon demo-code.js

You will see ‘hello’ printed to the console.

Change the code in demo-code.js to:

console.log('hello again')

Save your file while watching the console. You will see ‘hello again’ printed.


References

All done!

klequis

Technical blog by klequis