DEV Community

mukul
mukul

Posted on

1 1 1 1

ExpressJs without nodemon

In this article, we’ll show you how to use the --watch flag, What is the --watch Flag?

The --watch flag is a feature in Node.js that allows your server to automatically restart whenever you change your code. It works just like nodemon, but without needing to install any third-party packages.

How to Use the --watch Flag
Update package.json
{
"name": "express",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"serve": "node index",
"dev": "node --watch index"
},
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"express": "^4.21.1"
}
}

Now run the script

npm run dev

Your server will restart whenever you make changes to your code like nodemon does.

Top comments (1)

Collapse
 
dikshafudugo profile image
Dikshafudugo

Working thanx 👍

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay