How can I run the Node.js application forever on the port that I installed on the command line?

I am trying to use this command, which should work. It does not seem to go through the environment variable when starting a server that uses Express.js. This is for this open source project, Bus Ticker .

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

There app.jsis this line in, so I expect that I can set the environment variable on this command line, as shown above.

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

+4
source share
1 answer

You set a shell variable, not an environment variable. Yes, the difference is confused.

Try putting exportat the beginning of this line.

+6

Source: https://habr.com/ru/post/1542842/


All Articles