The Wayback Machine - https://web.archive.org/web/20240907054004/https://www.geeksforgeeks.org/node-js-automatic-restart-node-js-server-with-nodemon/
Open In App

Node.js Automatic restart Node.js server with nodemon

Last Updated : 14 Oct, 2021
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

We generally type following command for starting NodeJs server:

node server.js

Image

In this case, if we make any changes to the project then we will have to restart the server by killing it using CTRL+C and then typing the same command again.

node server.js

It is a very hectic task for the development process.

Nodemon is a package for handling this restart process automatically when changes occur in the project file.

Installing nodemon: nodemon should be installed globally in our system:

Windows system: npm i nodemon -g
Linux system: sudo npm i nodemon -g 

Image

Now, let’s check that nodemon has been installed properly to the system by typing the following command in terminal or command prompt:

nodemon -v

It will show the version of nodemon as shown in the below screenshot.

Image

Starting node server with nodemon:

nodemon [Your node application]

Image

Now, when we make changes to our nodejs application, the server automatically restarts by nodemon as shown in the below screenshot.

Image

In this way with nodemon server automatically restarts.



Similar Reads

Node.js nodemon npm Module
The nodemon npm Module is a module that develop node.js based applications by automatically restarting the node application when file changes in the directory are detected. Nodemon does not require any change in the original code and method of development. Advantages of Using nodemon Module: It is easy to use and easy to get started.It does not aff
1 min read
How to Start, Stop, or Restart Apache Server on Ubuntu?
Apache is a popular software used to run websites on the internet. Many websites, online applications, and AI programs use Apache. Apache is popular because it works well with other software and can handle a lot of users visiting the website at the same time. For people running Apache on Ubuntu computers, it is important to know how to start, stop,
3 min read
How to restart Node.js application when uncaught exception happen ?
In this article, we are going to learn, about restarting a Node.js application when an uncaught exception happens. For this, we are going to use the pm2 module. Approach: Let's see the approach step by step: Step 1: Install the pm2 module and use it to start the server.Step 2: When an uncaught exception happens, then execute the command process.exi
2 min read
D3.js timer.restart() Function
The timer.restart() function in D3.js is used to restart a timer with the given function and delay. The timer.restart() function is used when one wants to reset the timer and start again. Syntax: timer.restart(callback, delay); Parameters: It takes two parameters as mentioned above and described below: callback: It is the function to be stopped or
2 min read
React Bootstrap @restart/ui utilities
React Bootstrap @restart/ui utilities is a set of utility classes provided by the React Bootstrap library that allows developers to easily style their components without writing custom CSS. These utilities cover various styles such as spacing, typography, colors, and more, making creating visually appealing and responsive UIs in React applications
3 min read
SVG restart Attribute
The restart attribute is used to decide whether an animation will restart or not. The attribute is used by the <animate>, <animateColor>, <animateMotion>, <animateTransform> and <set> elements. Syntax: restart="always | whenNotActive | never"Attribute Values: This attribute accepts three values as mentioned above and d
2 min read
Automatic Captcha Verification using JavaScript
Captcha: Captcha is a program used to protects websites through bots. It generates some tests that human can read and pass it but current computer can not do. For example, humans can read distorted text but computer can not read. The CAPTCHA is the abbreviation of Completely Automated Public Turing Test To Tell Computers and Humans Apart. There are
1 min read
Next.js Automatic Updates
Next.js is a popular open-source React framework used for building scalable and high-performance web applications. One of the exciting features of Next.js is automatic updates, which help to keep your application up to date with the latest improvements and security patches without any manual intervention. What are Next.js Automatic Updates? Next.js
2 min read
SASS --watch with automatic minify
SASS is the abbreviation of Syntactically Awesome Style Sheets. It is a CSS pre-processor with syntax advancements. The stylesheets in this syntax are processed by a program and compiled into regular CSS style sheets, which can be used in the website. You can read more about SCSS by clicking here. In this tutorial, we will discuss the various metho
3 min read
Semantic-UI Grid Column Automatic Flow
Semantic UI is a modern framework used in developing seamless designs for web pages, It gives the user a lightweight experience with its components. It uses predefined CSS and jQuery to incorporate different frameworks. It makes web pages look amazing and responsive. Semantic UI Grid is used to harmonize negative space in a layout. The grid layout
3 min read
Semantic-UI Grid Automatic Column Count
Semantic UI is an open-source framework that uses CSS and jQuery to build great user interfaces. It is the same as a bootstrap for use and has great different elements to use to make your website looks more amazing. It uses a class to add CSS to the elements. Semantic-UI Grid layout is used to harmonize the negative space layout. The grid element i
3 min read
What is Automatic Batching in React 18
React 18 includes great features including automatic batching, which enhances rendering effectiveness and results in significant gains for programmers and users. This article is going to explain what batching is, how it worked before in React, and how our lives have been changed by automatic batching. Table of Content What is Batching?Batching in R
4 min read
How to Add Automatic Serial Number in HTML Table ?
Adding automatic serial number to an HTML table is a common requirement for displaying data in a structured format. Serial numbers help users to easily identify and refer to individual rows in a table. In this article, we will discuss two methods to add serial numbers to an HTML table i.e. using HTML and using JavaScript for dynamic tables. Add Aut
3 min read
Automatic Image Slider using JavaScript
In this article, we will discuss how to create an automatic image slider using JavaScript. An image slider is a popular component of modern websites that allows the display of multiple images in a single location, usually in a sliding motion. With the use of JavaScript, creating an automatic image slider has become much simpler. Preview: Approach:T
3 min read
How to create automatic pop-up using jQuery ?
In this article, we will be showing you how to make a custom automatic Pop-up box for subscribing to any service. You might have often come across a Pop-up box asking to subscribe to any services when you visit any particular site. Hence in this article, you will learn how to customize that Pop-up box and make your own. We will be using simple HTML
4 min read
Next.js Automatic Static Optimization
Next.js Automatic Static Optimization is a powerful feature that enhances the performance of web applications by optimizing static content generation. It intelligently determines whether a page can be statically optimized based on the data-fetching methods used. In this article, we will learn about Automatic static optimization in NextJS. Next.js A
2 min read
How to Automatic Refresh a Web Page in a Fixed Time?
Automatic refresh of a web page at a fixed time refers to reloading the page at regular, predefined intervals. This can be achieved using the HTML <meta> tag or JavaScript's setInterval() function, ensuring the content stays updated without manual user intervention. There are two methods to automatically refresh a web page in a fixed time: Ta
2 min read
Difference between Apache Tomcat server and Apache web server
Apache Tomcat server: Apache Tomcat is a web container. It allows the users to run Servlet and JAVA Server Pages that are based on the web-applications. It can be used as the HTTP server. The performance of the Tomcat server is not as good as the designated web server. It can be used as separate product with its own internal Web-server. It can also
2 min read
Difference between Web Server and Mail Server
Web Server : Web Server, as the name suggests, is a server software where web content is stored and uses HTTP protocol and other protocols to respond to user requests that is being made over WWW. Its main function is to display the content of the website through storing, processing, and delivering webpages within the website to users. Example: Apac
4 min read
How to install and configure Apache Web Server on Godaddy Server?
GoDaddy VPS is a shared server that provides computational services, databases, storage space, automated weekly backups, 99% uptime, and much more. It’s a cheaper alternative to some other popular cloud-based services such as AWS, GPC, and Azure. Apache HTTP Server is an open-source web server software widely used by web hosting companies to provid
2 min read
Server Side Rendering vs Client Side Rendering vs Server Side Generation
In the world of web development, there are several approaches to rendering web pages: server-side rendering, client-side rendering, and server-side generation. Each approach has its own advantages and disadvantages, and choosing the right one for your project depends on your specific needs and goals. In this blog, we’ll explore the differences betw
4 min read
Difference Between Web server and Application server
A server is a central repository where information and computer programs are held and accessed by the programmer within the network. Web server and Application server are kinds of the server which employed to deliver sites and therefore the latter deals with application operations performed between users and back-end business applications of the or
2 min read
How to Install Apache Web Server on Linux Cloud Server?
Apache is an open-source web server used widely for hosting websites and web applications. It's popular on the internet and supports platforms like Linux, Windows, and macOS. Installing Apache on a Linux-based cloud server is straightforward. Cloud servers offer flexibility and scalability, enabling easy management and deployment of computing resou
5 min read
Build a Simple static file web server in Node.js
In this article, we will build a static file web server which will list out all the files in the directory and on clicking the file name it displays the file content. Steps for creating a static file server is as follows: Step 1: Importing necessary modules, and defining MIME types which helps browser to understand the type of file that is being se
4 min read
How to Set Online SQL Server for Node.js ?
An Online SQL server helps to connect your project with an online server instead of localhost database setup. To achieve this, the remotemysql site is popular for providing an online database to store our data in a secure way. Installation of sql module: You can visit the link Install sql module. You can install this package by using this command.n
2 min read
Node.js Server Side Rendering (SSR) using EJS
Server-side rendering (SSR) is a popular technique for rendering a normally client-side-only single-page app (SPA) on the server and then sending a fully rendered page to the client. The client's JavaScript bundle can then take over and the SPA can operate as normal. SSR technique is helpful in situations where the client has a slow internet connec
3 min read
How to connect mongodb Server with Node.js ?
mongodb.connect() method is the method of the MongoDB module of the Node.js which is used to connect the database with our Node.js Application. This is an asynchronous method of the MongoDB module. Syntax: mongodb.connect(path,callbackfunction) Parameters: This method accept two parameters as mentioned above and described below: Path/URL: The Path
2 min read
Node.js server.close() Method
The server.close() is an inbuilt application programming interface of class Socket within tls module which is used to stop the server from accepting the new client request. Syntax: const server.close() Parameters: This method does not accept any parameter. Return Value: This method return nothing but a callback function for listening the server ins
3 min read
Node.js server.address() Method
The server.address() is an inbuilt application programming interface of class Socket within tls module which is used to get the bound address of the server. Syntax: const server.address() Parameters: This method does not accept any parameter. Return Value: This method returns the bound address containing the family name, and port of the server. How
3 min read
Node.js server.getTicketKeys() Method
The server.getTicketKeys() is an inbuilt application programming interface of class Socket within tls module which is used to get a 48-byte buffer containing the session ticket keys. Syntax: const server.getTicketKeys() Parameters: This method does not accept any parameter. Return Value: This method returns a 48-byte buffer containing the session t
3 min read