[nodemon] clean exit – waiting for changes before restart

The message “[nodemon] clean exit – waiting for changes before restart” usually appears when using the nodemon tool in a Node.js project. It indicates that nodemon is currently waiting for changes to the project files before automatically restarting the server.

Nodemon is a utility that monitors changes in the project’s files and automatically restarts the server when any changes are detected. This can be particularly useful during development when you want the server to restart automatically after making changes to the code.

Here’s an example to illustrate how nodemon works:

    
      // index.js
      const http = require('http');
      
      const server = http.createServer((req, res) => {
        res.end('Hello, world!');
      });
      
      server.listen(3000, () => {
        console.log('Server is running on port 3000');
      });
    
  

In the example above, we have a simple Node.js server listening on port 3000. Normally, if we run this script using the “node” command (e.g., node index.js), the server will start and keep running until we manually stop it.

However, if we use nodemon to run the script (e.g., nodemon index.js), nodemon will not only start the server but also monitor the project files for any changes. If we make changes to the code (e.g., modify the response string), nodemon will detect the changes and automatically restart the server, allowing us to see the updated response without manually stopping and restarting the server.

The message “[nodemon] clean exit – waiting for changes before restart” is shown by nodemon when the server is stopped gracefully and it’s waiting for new changes to occur before restarting. It indicates that nodemon is still running and watching for any modifications in the project files.

Read more interesting post

Leave a comment