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
- Multiple stale Node.js processes are running in the background.
- Having an error in your code that causes nodemon to crash.
- An incorrect path to the file you are trying to run when issuing the nodemon command.
- 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:
- Try to restart your Nodemon server.
- Stopping all Node.js processes on Windows, macOS, and Linux.
- Check your code for errors. If you can run your app manually without any errors, then the problem is likely with the nodemon configuration.
- Try using a different version of the nodemon. Sometimes, a newer version of the nodemon may fix the problem.
- Ensure your database runs before you start your nodemon server; otherwise, an error is raised, and the nodemon crashes.
- Think about the recent changes you made. Often, the issue might be related to the last few changes in the code.
- Ensure that all required environment variables are set correctly.
- If you’re unsure about the cause, add console.log statements or use a debugger to step through your code.
- Ensure that all necessary npm packages are installed and that no conflicting versions exist.
- 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.