Search code examples
node.jsforevernodemon

nodejs + nodemon + forever give me an error


I just installed forever globally (-g). Before that I used to run with

$ npm start

Now after installed forever, I tried to lunch the node app

$ NODE_ENV=development forever nodemon server.js

but I receive this error

warn:    --minUptime not set. Defaulting to: 1000ms
warn:    --spinSleepTime not set. Your script will exit if it does not stay up for at     least 1000ms
error:   Cannot start forever
error:   script /path/to/app/nodemon does not exist.

the same also with

$ NODE_ENV=development forever nodemon server.js

any idea?


Solution

  • The error you received in your output:

    error: script /path/to/app/nodemon does not exist.

    It appears that forever is looking for nodemon in the current working directory, and can't find it because it doesn't exist there. Try providing the absolute path when starting nodemon, which can be found with which nodemon.

    forever start /usr/local/bin/nodemon server.js
    

    Note that the start flag is what puts the application in daemon mode.