Bootcamp
Search…
0.6: Nodemon

Introduction

​Nodemon is an application that restarts our server every time we change a file that the server depends on. This is especially useful in development when we are making regular changes to our server code.

Usage

  1. 1.
    Instead of running node index.js, which requires us to Ctrl+C and restart our server every time we make code changes, we can use Nodemon.
  2. 2.
    Install Nodemon globally to avoid stopping and starting our server every time our files change. This makes the command available globally on our system.
    1
    npm i -g nodemon
    Copied!
  3. 3.
    Running the following command to start our server will cause our server to restart each time we save a file it depends on. The -e js argument tells Nodemon to only restart on changes to JS files. By default Nodemon also "watches" (i.e. restart on changes) JSON files, which can be troublesome when we work with JSON files as DBs.
    1
    nodemon index.js -e js
    Copied!
  4. 4.
    Once we transition to SQL DBS, feel free to use nodemon without the -e argument.
Copy link