Good Bye nodemon
Nodemon is a tool that is used for automatically restarting a Node.js application whenever there are changes made to its source code. It can be useful for developers who are working on a Node.js project as it saves them time and effort by eliminating the need to manually stop and start the application after each change.
Nodemon can be installed globally using the Node Package Manager (npm) by running the following command:
npm install -g nodemon
Once installed, you can start your Node.js application using nodemon by running the following command:
nodemon app.js
But it is time to say good bye nodemon
Node.js 19 introduces the experimental?--watch?flag, which restarts?a nodejs server?when it detects changes in the specified file.
To restart your Node.js server using the?--watch?flag, run the?node?command with the?--watch?flag followed by the name of the file you want to restart when Node detects changes.
For example: server.js?file:
// server.js
const express = require("express");
const app = express();
const PORT = 3000;
app.listen(PORT, () => console.log(`App listening on port: ${PORT}`));
To watch this file for changes, and restart the server when they occur, run this command on your terminal
node --watch server
The command will watch your server.js file and restart the Node.js server when it detects changes made in the file.
It is worth noting that this feature is still experimental, which means you may experience issues while using the?--watch?flag to restart your server.