简体   繁体   中英

nodemon keeps crashing waiting for file changes

Cloned a project that I completed 2 months ago, and unfortunately, nodemon won't run. I've tried using task manager on windows to close npm and run it again and I still keep getting the same error. I'm also using monogodb as my database as well if that helps.

I've left a link here to my repository if anybody can help?

https://github.com/Tashfinz/ExpressNodeBlog

Error:

 $ nodemon server [nodemon] 2.0.4 [nodemon] to restart at any time, enter `rs` [nodemon] watching path(s): *.* [nodemon] watching extensions: js,mjs,json [nodemon] starting `node server global.js` C:\Users\tashf\Documents\Projects\ExpressNodeBlog\global.js:17 console.log(document.querySelector); ^ ReferenceError: document is not defined at Object.<anonymous> (C:\Users\tashf\Documents\Projects\ExpressNodeBlog\global.js:17:13) at Module._compile (internal/modules/cjs/loader.js:1251:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10) at Module.load (internal/modules/cjs/loader.js:1100:32) at Function.Module._load (internal/modules/cjs/loader.js:962:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) at internal/main/run_main_module.js:17:47 [nodemon] app crashed - waiting for file changes before starting...

You need to kill the node server process

in Windows, go to task manager and end the process.

Now run the node server: example- “nodemon server.js”

in most cases, it should work else try “npm install” to re-install the packages then try “nodemon server.js”.

I hope this would help.

uninstall and install again works for me

npm un nodemon
npm i nodemon

Reasons & Solutions:

First:

Maybe your PC running several processes in the Background. So you need to stop all the node process that are running.

Quick trick:

Kill them all by running this on terminal:


pkill -f node

or to kill a particular port instead of all


sudo lsof -i :3000//replace 3000 with your port number

sudo kill -9 31363// replace 31363 with your PID

and then restart nodemon.

Second:

Server.js and package.json are not in the same folder.

check package.json File.

And In MAIN YourNode.js file and SCRIPT start: nodemon YourNode.js has SAME NAME.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM