What is Nodemon?

In order to run Node.js applications one would have to type node along with the filename.

node filename.js

This process has to be repeated every time you want to run code. But let’s say you have a program that automatically runs your code whenever you make updates to the application? Wouldn’t that be great? It would save you time from the repetitive process of executing a command.

Fortunately such a program exists and it is called “Nodemon”. Nodemon monitors changes in your code and then automatically restarts your server whenever there is a change.

How to Install Nodemon?

Just Enter this command on the terminal

npm install -g nodemon




Node.js- The benefits of package.json

In my previous blogs, I talked about how to setup a node.js environment on a Mac and describing what npm is. Npm is used to Install packages or dependencies in a project folder. There is a file called package.json that lists the packages Installed.

This is how package.json looks like-

Screen Shot 2018-02-22 at 8.55.30 PM.png

As you can see the dependencies in this file are nodemon and typescript. In a Node.js project you would something called as node_modules. The node_modules Include the libraries and packages Installed for the project.

Here is an example of a file structure for a Node.js Project

Screen Shot 2018-02-22 at 9.02.01 PM

Incase one accidentally the node_modules folder, how can we retrieve or Install the dependencies?

This is where package.json is of help to us. Since package.json stores the list of dependencies that you Installed in the project, all you have to do is run

npm install

Once you run this on the command line, the node package manager would scan the package.json file and Install the dependencies from there. And from that you would get the node_modules folder back.

Installing dependencies using npm

npm also known as the node package manager is used to Install dependencies for a project. Dependencies are files that are needed in order for a project to compile and build successfully. Without Installing dependencies, the project would always run Into errors.

Node Package Manager is a one stop shop for Installing dependencies. Without a package manager life would be quite chaotic. One would have to go from one website to another in order to Install files since they are scattered all across the web. It’s akin to shopping in mall where you can get everything in one place rather than going to different stores across the street. It’s a matter of perception which you find more easier or convenient.

As discussed, node package manager allows you to Install all the required files from one place. All you would have to do is just type this command in a terminal or a command prompt.

npm install

Installing Node.js on a Mac

Node.js allows one to run JavaScript outside the browser. It is especially useful for running React which is a JavaScript framework. You could either Install Node.js by downloading the package from their website or use a Package Manager. Installing it via a package manager is the preferred method.

A package manager for Mac that you could use is Home Brew. In order to Install the Package Manager enter the following command in the terminal

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Home


This Installs the Package Manager. The next step is Installing Node.js and NPM which is a package manager for JavaScript. All you have to do is type this command in the terminal

brew install node

This Installs Node.js and NPM. In order to ensure that node.js has been Installed, type this command in the terminal

node -v

If it returns a version number, it means that node.js has been successfully Installed.

Let’s summarise, there are two steps in Installing Node.js

  1. Install a Package Manager for Mac. In this case we have Installed HomeBrew.
  2. Once Installed, Install node by typing the install node command in the terminal.