Reputation: 235
How do you run the Express 4 app with Forever? (or is there a new package?)
I am running my Express 3 apps with Forever installed locally with the package manager. I use the command:
forever -a start app.js
Upvotes: 18
Views: 20090
Reputation: 27395
Feb 2021
This solution is for express.js & forever, on Windows OS.
package.json
"scripts": {
"start": "set PORT=3001 && set DEBUG=myapp:* && forever start --minUptime 1000 --spinSleepTime 1000 ./bin/www",
}
Now run:
npm start
NOTE: For other OS, and customization see following link: https://expressjs.com/en/starter/generator.html
Upvotes: 0
Reputation: 377
If you use npm start to run your app, this works in place of it:
forever start -c "npm start" /path/to/app/dir/
Source: https://github.com/foreverjs/forever/issues/540
Upvotes: 2
Reputation: 317
Try node app.js
first, for me, I added a new module in code base, but i did not run npm install
in my AWS box, forever is not giving you the error, it just stopped silently, but node will give you the error
Upvotes: 1
Reputation: 815
Try this:
forever start ./bin/www
Let's take a look to package.json
:
"scripts": {
"start": "node ./bin/www"
},
I guess when we call npm start
, ./bin/www
will be executed at some point.
Then look at the content of./bin/www
:
var server = app.listen(app.get('port'), function() {
debug('Express server listening on port ' + server.address().port);
});
so we are ready to listen for connections.
Upvotes: 24
Reputation: 17
http://expressjs.com/guide.html
in Expressjs guide doc,
use 'npm start'
I want use 'forever' but can not too
so,
add code at 'app.js'
var server = app.listen(3000, function() {
console.log('Listening on port %d', server.address().port);
});
and
$node app.js
can use it.
and forever can use too
Upvotes: 0