Brennan
Brennan

Reputation: 11686

How can I start a Node.js app with forever on a port that I set on the command-line?

I am trying to use this command which should work. It does not seem to pass along the environment variable when starts the server which uses Express.js. This is for this Open Source project, Bus Ticker.

PORT=8081; forever start ./website/app.js

In app.js is has this line so I am expect that I can set the environment variable on that command-line as shown above.

app.set('port', process.env.PORT || process.env.npm_package_config_port || 3000);

Upvotes: 4

Views: 2491

Answers (1)

Chris Tavares
Chris Tavares

Reputation: 30411

You're setting a shell variable, not an environment variable. Yes, the distinction is confusing.

Try putting export at the beginning of that line.

Upvotes: 6

Related Questions