nodemon

Install Nodemon and how to deal with potential issues

Nodemon will monitor any changes in your code and automatically restart your server. This removes the need to type in node server.js to start, restart webpage to see changes, control+c to stop, and repeat after every single little change. You can read more about it here.

In a perfect world, this first step should work for you and be done. You can stop reading. In your terminal, it doesn’t need to be in a project folder, type this to download it to your computer.

npm install -g nodemon

Potential Issues

If that doesn’t work for you, then try this.

sudo npm install -g nodemon

You will need to enter a password so make sure you have admin privileges on your computer. If it’s your computer and not a job or school’s, then this shouldn’t be a problem.

Note: Your password won’t show up when you type it.

After installing Nodemon, if you try to run it and get a long error list, you can get rid of it by entering:

npm i pstree.remy@1.1.0 -D

The documentation for this issue can be found here on GitHub.

You should be good to go now!

Conclusion

Once you have it downloaded, you can go to your folder in the terminal and instead of typing node server.js, you can type nodemon server.js. It is now monitoring for changes. Every time you hit save, nodemon will automatically restart the server and you just need to refresh the browser to see your updates.

Hopefully this has helped someone to become 1 step closer to becoming a better developer.

Leave a Reply