nodemon script nodejs

What is nodemon script in Node.js?

If you have experience with Node.js, you may come across the term nodemon script. Nodemon is a tool that helps you develop Node.js-based applications by automatically restarting the Node.js application when file changes are detected in the directory. This is especially useful when you are making frequent changes to your code and want to see the changes reflected without manually restarting the server.

To use Nodemon, you need to install it globally or locally to your project. Once you have installed Nodemon, you can create a nodemon script in Node.js that tells Nodemon which file to watch and restart when changes are detected. The nodemon script can be defined in the package.json file of your project.

Creating a nodemon script in Node.js

To create a nodemon script in Node.js, you need to follow these steps:

  • Step 1: Install Nodemon globally or locally to your project using npm.
  • Step 2: Open the package.json file of your project.
  • Step 3: Add a nodemon script to the scripts section of the package.json file.
  • Step 4: Specify the file to watch and restart using Nodemon.
  • Step 5: Save the changes.

Here is an example of a nodemon script in Node.js:

  "name": "my-app",
  "version": "1.0.0",
  "description": "My Node.js app",
  "scripts": {
    "start": "node index.js",
    "dev": "nodemon index.js"
  "dependencies": {
    "express": "^4.16.4"

In the above example, the nodemon script is defined as "dev": "nodemon index.js". This means that Nodemon will watch the index.js file for changes and restart the server automatically when changes are detected.

Using nodemon script in Node.js can save you a lot of time and effort while developing your application. With nodemon, you can focus on writing code and making changes without worrying about manually restarting the server every time.

Subscribe to The Poor Coder | Algorithm Solutions

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]