Search code examples
node.jsforevernodemon

Forever + Nodemon running together


Is there any way to have both of this packages running together?

So basically I want to have best from both worlds. Running server automatically (and restarting when there is an error) and also automatic updates when there is .js file change happening.


Solution

  • Toxa was on the right track, the issue that cfogelberg raised is valid, but to avoid that issue you can do the following:

    forever -c "nodemon --exitcrash" app.js
    

    this makes sure nodemon actually exits (rather than giving you the "app crashed" message) and then forever picks it up again.

    In forever --help this -c specifies a command to run otherwise it defaults node. Without -c results in the error that is mention in the comments to this answer.