DEV Community

mukul
mukul

Posted on

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 👍