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.

要查看或添加评论,请登录

Ajay Kumar的更多文章

  • How to use swagger in our express app ?

    How to use swagger in our express app ?

    Swagger is an open-source framework that enables developers to design, document, and consume Restful APIs effortlessly.…

  • Why should we use Angular?

    Why should we use Angular?

    Angular is a popular front-end framework that helps developers to build scalable and dynamic web applications.It is…

  • Use full tips for writing JavaScript code.

    Use full tips for writing JavaScript code.

    Use const for variables that don't change,and use let for variable we want to re-assignments of value Use arrow…

  • JavaScript is Everywhere

    JavaScript is Everywhere

    Today, new languages are being created to build a new level of applications that have advanced features and also meet…

社区洞察

其他会员也浏览了