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

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.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 41 (4 by maintainers)

Commits related to this issue

Most upvoted comments

here you will have a solution in simple steps

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

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.

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.

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.

@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...

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

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

@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

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"
  }

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.

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.

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.

Also having this issue with 4.2.6

  • Working fine in 5.6.0

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

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(),

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.

@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?

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