0

I been searching alot and no result with same problem as me. I have a Node.js application and I want to start it with forever start app.js, the process starts but no website found when i try in browser. The process is in the list when I write forever list.

Npm start works fine but I cant use nodejs/node app.js or my_file.js.. It gives no error or something just new command line with no output in terminal.

So anyone know why I cant start the app with nodejs app.js or forever start app.js .. No files works.

Thanks!

Severin
  • 8,508
  • 14
  • 68
  • 117
jerrkan
  • 97
  • 1
  • 6
  • Are you getting any errors when you run `node app.js`? – TMan Oct 04 '14 at 19:30
  • firstly, there is no commant like "nodejs app.js", only "node app.js". if it works - forever should work too. – Jarema Oct 04 '14 at 19:32
  • @Jarema - Actually they changed the default command for node recently so if you didn't have it from an earlier version, it defaults to using `nodejs` as the name of the executable.. Rather annoying – TMan Oct 04 '14 at 19:33
  • omg. I use node in some production enviroments, but with frozen dependencies... good for me. look at: http://stackoverflow.com/questions/24072812/forever-node-js-express-4 if You're using any code generators AND expressjs(i dont, so i dont know). – Jarema Oct 04 '14 at 19:35
  • @TMan No I don't get any errors, I output nothing. – jerrkan Oct 04 '14 at 19:41
  • Elyas74 answer doesnt help? Still - looking at package.json and "scripts" should help a lot. There is defined how app is starting. – Jarema Oct 04 '14 at 19:43
  • is your app working at all? Could you post some code/a gist? It sounds like the problem isn't with forever but with your application. – xShirase Oct 04 '14 at 19:46

2 Answers2

1

In express 4 you should write :

forever ./bin/www

And if you check your package.json file you can see :

"scripts": {
    "start": "node ./bin/www"
  }

It's the npm start script

Elyas74
  • 548
  • 1
  • 5
  • 18
0

Alternatively, you can try using PM2.

It does a great job at keeping your app alive, and has some really useful features such as load balancing, no downtime, and a web interface to monitor your processes.

In addition, I find it dead simple to use.

xShirase
  • 11,975
  • 4
  • 53
  • 85
  • 1
    I agree that pm2 is great... but for production. It tends keep port in use even after application is stopped/deleted, and the only way to solve it is to use pm2 kill, which kills all apps. Not a big deal, but it sometimes is frustrating in development. Especially if You have lot of apps on the same server. For production - its jsut great. – Jarema Oct 05 '14 at 05:19
  • @Jarema totally agree with you, the port thing is very annoying in development – xShirase Oct 05 '14 at 12:18