Node.js - Unable to run node server using forever

I am trying to run node server using forever command. I installed forever globally using:

npm install forever -g

After installing forever I try to run my node script by using below command:

node_modules\.bin\forever start app.js

Below is my console:

warn:    --minUptime not set. Defaulting to: 1000ms
warn:    --spinSleepTime not set. Your script will exit if it does not stay up f
or at least 1000ms
info:    Forever processing file: app.js

Please help me to resolve this issue!

There is no problem here other than warnings for configs forever recommends you declare. If you see the final message there it tells you it has processed your script. Just run forever list and you should see your script running.

I ran into this same thing when installing npm via yum repository ( yum install npm ) and then installing forever whereas when I install node and npm via shell scripts and then install forever it doesn't occur. It must have something to do with the formulas for the package installer or potentially missing alias with flags with installer to set those values behind the scene.

Those don't mean it's not working. See below I created a js file using sample code from node's site and ran it manually (I flushed firewall to open port for app temporarily but you don't need that):

[root@app1 ~]# vi example.js
[root@app1 ~]# apf -f
apf(23924): {glob} flushing & zeroing chain policies
apf(23924): {glob} firewall offline
[root@app1 ~]# node example.js 
Server running at http://127.0.0.1:1337/

I then start app using forever:

^C[root@app1 ~]# forever start example.js 
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
info:    Forever processing file: example.js

Now I check to see if my app is running:

[root@app1 ~]# forever list
info:    Forever processes running
data:        uid  command       script     forever pid   logfile                 uptime       
data:    [0] dan1 /usr/bin/node example.js 23976   23978 /root/.forever/dan1.log 0:0:0:27.320 
[root@app1 ~]#

This solved my issue:

forever start -c node [path/to/app]

"-c" means - Run commnad; and then just run via nodejs

This way - you get the Respawn by default of min. 1000ms uptime

Taken from: https://github.com/nodejitsu/forever/issues/422, by "Basarat"

If you setup a module globaly (-g option) "forever" is in the $path

forever start app.js

should work.

Try running

sudo forever start app.js