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:
- Run Numerous Node.js Processes
- Code-Related Issues
- Incorrect File Path
- Database Connectivity Problems
How to fix [nodemon] app crashed – waiting for file changes before starting…
Here are some solutions to fix this error:
Method 1: Kill All Node.js Processes on macOS and Linux
There may be multiple processes running simultaneously in the background, which may cause conflicts and generate errors.
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
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
Method 2: Kill 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
- Open the Command Prompt or PowerShell.
- Use the following command to list all Node.js processes:
- tasklist | find “node.exe”
- To terminate a Node.js process, use the following command, replacing
<PID>
with the actual Process ID:- taskkill /F /PID
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
Method 3: Set Incorrect File Path
If package.json and server.js files are not in the same directory, the error will occur, you can set the path of your package.json and server.js or app.js like this:
"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" },
Method 4: Database Connectivity Problems
If your database server is down for some reason, this error can also occur.
Method 5: An alternative command to fix
The alternative nodemon command to fix nodemon crash 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.