Nodemon App Crashed – Waiting For File Changes Before Starting

Nodemon App Crashed – Waiting For File Changes Before Starting

Nodemon is a utility that monitors for changes in your source code and automatically restarts the Node.js application when changes are detected. The message “nodemon app crashed – waiting for file changes before starting” typically appears when you are using Nodemon to run a Node.js application, and the application crashes for some reason.

The error message “[nodemon] app crashed – waiting for file changes before starting” can occur for a number of reasons, including in windows, Linux and mac:

  1. Run Numerous Node.js Processes: The presence of multiple, waiting Node.js processes in the background can trigger this error. Ensure that you terminate any existing Node.js instances before running nodemon again to avoid conflicts.
  2. Code-Related Issues: Errors within your codebase may lead to nodemon crashes. Thoroughly inspect your code for syntax errors, runtime exceptions, or unhandled issues. Rectify these problems and save your files to enable nodemon to restart the application successfully.
  3. Incorrect File Path: If the path specified in the nodemon command is incorrect or leads to a non-existent file, nodemon will encounter difficulties initiating the application. Verify that the path points to the correct entry file and that the file exists in the specified location.
  4. Database Connectivity Problems: Nodemon may crash when attempting to connect to a database that is currently offline or inaccessible. Confirm the availability and proper configuration of your database connection. If the database is down, bringing it online should prevent nodemon from encountering a crash.

Fixed – Nodemon App Crashed – Waiting For File Changes Before Starting

Here are a few solutions to fix nodemon app crashed – waiting for file changes before starting in Windows, Linux and Mac system:

  • Kill/Stop/Terminate All Node.js Processes on macOS and Linux
  • Kill/Stop/Terminate All Node.js Processes on Windows
  • Set Incorrect File Path
  • Database Connectivity Problems
  • An alternative command to fix

Kill/Stop/Terminate All Node.js Processes on macOS and Linux

It’s possible that multiple Node.js processes are concurrently running in the background, leading to conflicts and the emergence of the error.

Kill/Stop/Terminate all ongoing Node.js processes and initiate a restart of Nodemon.

For macOS and ubuntu Linux users, access the bash terminal and execute the below given command.

# for macOS and Ubuntu Linux

pkill -f node

If you found any issue while running the above given command. So, you can try to run the command prefixed with sudo.

# for macOS and Ubuntu Linux

sudo pkill -f node

Once you have stopped all running processes in node js, you need to restart your nodemon server by using the following command:

npx nodemon server.js

Or if you have installed nodeman globally, so you can use the following command:

nodemon server.js

Kill/Stop/Terminate All Node.js Processes on Windows

Below are two ways to Kill/Stop/Terminate all Node.js processes on Windows.

Using Task Manager

  • Press Ctrl + Shift + Esc to open Task Manager.
  • In the “Processes” tab, find any processes related to Node.js (e.g., node.exe).
  • Select the processes and click on “End Task” or “End Process.”

Using Command Prompt

  1. Open the Command Prompt or PowerShell.
  2. Use the following command to list all Node.js processes:
    • tasklist | find “node.exe”
  3. To terminate a Node.js process, use the following command, replacing <PID> with the actual Process ID:
    • taskkill /F /PID

Once you have stopped all running processes in node js, you need to restart your nodemon server by using the following command:

npx nodemon server.js

Or if you have installed nodeman globally, you can use the following command:

nodemon server.js

Set Incorrect File Path

If package.json and server.js file will not be in the same directory then the error will occur.

So you can set the path of your package.json and server.js or app.js like this.

Let us understand with an example. Here is the script section of my package.json file.

"scripts": {
  "dev": "nodemon server.js",
}

Or if your server.js or app.js file is a directory then you have to set the path like this.

"scripts": {
  "dev": "nodemon ./app/server.js"
},

Database Connectivity Problems

If your database server is stopped. For some reason. So even then this error may occur.

So first check that your database server is started properly and working. otherwise an error will occur and Nodemon will crash.

An alternative command to fix

Here is alternative nodemon command to fix nodemon crashed error; is as follows:

nodemon --exitcrash

Conclusion

That’s it; you have learned some ways to fix error “[nodemon] app crashed – waiting for file changes before starting in windows, linux and mac system.

Recommended Tutorials

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *