How to Fix [nodemon] app crashed – waiting for file changes before starting

The [nodemon] app crashed – waiting for file changes before starting error occurs when “there is an error in your code that causes nodemon to crash.”

Nodemon is a utility that monitors for changes in your Node.js application and automatically restarts the server. This is extremely helpful in development because you don’t need to restart the server each time you change manually.

Common reasons for the error

  1. Multiple stale Node.js processes are running in the background.
  2. Having an error in your code that causes nodemon to crash.
  3. An incorrect path to the file you are trying to run when issuing the nodemon command.
  4. Attempting to connect to a database that is offline causes nodemon to crash.

How to fix the error?

Here are some solutions to fix the [nodemon] app crashed – waiting for file changes before starting error.

  1. Try to restart your Nodemon server.
  2. Stopping all Node.js processes on Windows, macOS, and Linux.
  3. Check your code for errors. If you can run your app manually without any errors, then the problem is likely with the nodemon configuration.
  4. Try using a different version of the nodemon. Sometimes, a newer version of the nodemon may fix the problem.
  5. Ensure your database runs before you start your nodemon server; otherwise, an error is raised, and the nodemon crashes.
  6. Think about the recent changes you made. Often, the issue might be related to the last few changes in the code.
  7. Ensure that all required environment variables are set correctly.
  8. If you’re unsure about the cause, add console.log statements or use a debugger to step through your code.
  9. Ensure that all necessary npm packages are installed and that no conflicting versions exist.
  10. Before this message, some error logs should indicate what went wrong. This is usually the most direct way to understand the issue.

Once you have identified and fixed the issue, save your files, and nodemon will attempt to restart your application.

If everything is okay, it should run without crashing. If not, it will provide more logs, which you can use for further troubleshooting.

That’s all!

Related posts

zsh: command not found: nodemon

Leave a Comment