remy/nodemon

[nodemon] app crashed - waiting for file changes before starting...

Closed this issue ยท 41 comments

I have this situation where I had a perfectly working app and all the request were not a problem at all. But after changing this piece of code:

exports.read = function (req, res) {
  res.json(req.external);
};

into:

exports.read = function (req, res) {
  //res.json(req.external);
  console.log(req.external);
  console.log('start----------');
  External.findById(req.external._id)
    .populate('user', 'displayName')
    .populate('articles')
    .exec(function (err, external) {
      console.log('in execution mode');
      if (err) {
        console.log('ERROR ERROR ERROR');
        return res.status(400).send({
          message: errorHandler.getErrorMessage(err)
        });
      } else {
        console.log('There is no error generated!');
        res.json(external);
      }
    });
};

After a few seconds my app crashes, although it sends the correct information to the
front-end? Anyone a solution? Because I have no clue how to fix this and at the moment I'm stuck.
The code doesn't get into the console.log('ERROR ERROR ERROR'); part.

remy commented

Does this crash if you use node and not nodemon? (i.e. just running the 2nd code block).

@remy Hey, I have the same problem. Code that works with node, will crash nodemon, and it is ALWAYS because of console.log statements contained in callbacks that print referenced data.

So console.log('test') will not crash nodemon, but console.log(db_results) or console.log(error) where db_results is an array of objects and error is a multi-line string will reliably crash nodemon.

My coworker doesn't seem to have this issue, but I certainly do.

Removing console logs fixes the issue, but this isn't exactly acceptable for obvious reasons.

I'm running the newest version of node (5+) on OSX

@remy Hi, even I have the issue. If I run from node, it runs perfectly allright. But if i run from nodemon, its crashing :

$ nodemon
[nodemon] 1.8.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `./node_modules/.bin/babel-node --presets react,es2015 server.js`
'.' is not recognized as an internal or external command,
operable program or batch file.
[nodemon] app crashed - waiting for file changes before starting...

I think the biggest issue is nodemon hiding error messages, or crashing just before displaying them. I have recently come up against a few cases where when running nodemon all I get is [nodemon] app crashed - waiting for file changes before starting... but if I run the server by itself with node, I get a full explanation/stack trace as to why the app crashed.

Otherwise, it seems nodemon is watching too many files for my system to handle, I believe this is an issue with my own setup as much as it is with nodemon. When using a lot of node_modules (and some python libraries) there are A LOT of files to watch, most of which I don't need to watch. I have attempted to use nodemon.json to exclude certain patterns... "node_modules/**" for instance, but it doesn't seem to have any effect.

Had this issue with node ver 4.2.6, but not when downgrading back to 4.2.2.

Also having this issue with 4.2.6

  • Working fine in 5.6.0
remy commented

Has anyone attempted to debug this yet?

Hey guys,
I had it happen to me, don't know if for the same reason.
My problem was I forgot to close pm2 running my production version before attempting to start nodemon.
Only after a while did nodemon give me an error saying it can't listen on the already bound port.

It happened to me as well. It crashes without giving any other error message.
I closed all the terminal window, and restarted it. Then it works again.

@remy also experiencing this issue regularly on OS X only when running nodemon. Haven't had time to debug but I can say that app in question that's wrapped with nodemon routinely outputs console messages ( have no idea if that's related or not however ) .. no error message reported other than what's been listed by previous commenters. Was not using pm2, instead was simply running gulp which executed nodemon.

Does someone have a solution as opposed to confirming that this is a problem?

@remy This is happening to me on Windows 10 with node v6.9.4 and nodemon 1.11.0, but only when I pass the --debug flag. For some reason, the signal received by nodemon is null and it's expecting SIGUSR2. Maybe this is related to #335?

I am also having this same issue anyone could solved that...

Don't ask me why but if i change the port (it was 300 i put 3000) nodemon doesn't crash anymore.

mine is 3001 so what should i put?

worked for node 5.6.0 version.

"bcryptjs": "^2.4.3",
"body-parser": "^1.17.2",
"cors": "^2.8.4",
"express": "^4.15.3",
"jsonwebtoken": "^7.4.1",
"mongoose": "^4.11.3",
"passport": "^0.3.2",
"passport-jwt": "^2.2.1"

node => v6.10.0
npm => 5.3.0
nodemon => 1.11.0

npm install => done.

screen shot 2017-07-22 at 4 53 25 pm

probblem
[nodemon] app crashed - waiting for file changes before starting...

Temp solution: I have changing port when this error msg come, its working.

remy commented

Sorry folks, but this thread has become awfully confused. I'm going to close it and if anyone still has a specific issue (and can create a replicable example with a gist containing files required), then please go ahead and open a new issue and I can (or you - please do contribute) attempt a PR.

I have the same problem as many here.. I am new to node.js.. and while I have been reading your comments.. there is a possibility that the issue is nodejs version running with certain version of nodemon.. i am wondering what versions are you guys using..

I am running
"nodemon": "^1.17.3" and node.js 8.11.1 .. would you guys recommend that I downgrade to an earlier version of node.js or nodemon? if so, what is would be the best version pairing that you guys are running?

remy commented

@tech2crave I'd suggest opening a new issue with details of what you're seeing. The original issue was opened 2 years ago when node support was very different. Node 8 should be very well supported, so if you file the new issue with full information on how to replicate, that would be perfect

here you will have a solution in simple steps

http://devfacts.com/nodemon-app-crashed-error-fix/

Try this probably.
Run 'npm install monk --save' under your node project folder.
Then run 'nodemon' again.
This should fix the problem.

Hey everyone, updating nodemon from version 1.18.6 to 1.18.9 fixed the issue for me.

@mukuljainx 1.18.9 doesn't help.

Might be easier to debug if errors were surfaced instead of just [nodemon] app crashed - waiting for file changes before starting... ?

After some digging (removing code) I figured out it was buggy middleware. I suggest if anyone else is running into this while using Express, to do the same.

@corysimmons you are right, that error can be something wrong in the code. I am using express and mqtt, when I type some variable that wasn't declared I get that error. [nodemon] app crashed - waiting for file changes before starting...

For me, error messages were getting hidden by winston. My winston transport had handleExceptions: true. In my particular case, the port was already in use but that error only showed up on my logging server. When i set handleExeptions: false, I started to get the error message in my console.

Many times we closed the PC and left the project running, when we used it again and ran the project again, that error appeared. I always solved it, restarting the pc. Everything worked perfectly.

root@DC-Development:~# docker logs 511b1f3b6821
[nodemon] 1.19.1
[nodemon] to restart at any time, enter rs
[nodemon] watching: .
[nodemon] starting node ./bin/www
module.js:550
throw err;
^

Error: Cannot find module 'http-errors'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object. (/tvstyres/app.js:1:83)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
[nodemon] app crashed - waiting for file changes before starting...
Facing same Nodemon app crashed issue can any one help me in fixing the issue

I had it happen to me, but I just figured it out.

change
"dev:watch": "nodemon --watch './src/**/*' -e ts,tsx --exec 'ts-node' ./src/index.ts",
to
"dev:watch": "nodemon --watch ./src/**/* -e ts,tsx --exec ts-node ./src/index.ts",
just remove those single quotes.

I got the same error, the possible solution is to free up the port.
Use the following commands:
sudo pkill node
or
kill $(lsof -t -i:5000)
Instead of 5000, use your port number.

It happened to me also when I tried to run nodemon from CLI, but after I added it into my package.json script and run with npm it works, I don't know why, but hope this helps.

@aricjean thank you bro, it worked for me.

Try to open the task manager and kill the node.js processes.

It worked for me.

image

It worked for me !!!
see if your task manager or node.js is running, finish the task, close your project and open again by running on port 5000.

Issue still exists with below setup, tried all the steps mentioned above but none of them worked.
I'm working on MERN stack project

"devDependencies": {
    "nodemon": "^2.0.4"
  }

"engine": {
    "node": "14.8.0",
    "npm": "6.14.7"
  }

Same here i face the same problem nay Help?
at node:internal/main/run_main_module:17:47
[nodemon] app crashed - waiting for file changes before starting...

Updating node.js to v14 solves this issue on my PC

Same problem w/ v 2.0.16. Gives me the app-crash -waiting for files, but doesnt actually tell me where in this giant codebase I've inhereted the actual error is :(

For me it was also an issue with winston. I had to use the following logger:

 winston.createLogger({
    level: 'debug',
    format: winston.format.combine(
      winston.format.errors({ stack: true }),
      winston.format.metadata(),
    ),
    transports: new winston.transports.Console(),
  }),

Then you can add the following to make it look better:

      winston.format.timestamp(),
      winston.format.prettyPrint(),