How can I set the NODE_ENV variable/parameter to "production" when I'm using forever to start my node script
I got this so far:
forever start -l forever.log -o out.log -e err.log -a app.js
Node. js assumes it's always running in a development environment. You can signal Node. js that you are running in production by setting the NODE_ENV=production environment variable. This is usually done by executing the command.
We see that it in fact reads NODE_ENV and defaults to 'development' if it isn't set. This variable is exposed to applications via 'app. get(“env”)' and can be used to apply environment specific configurations as explained above, but it's up to you to use this or not.
NODE_ENV is an environment variable that stands for node environment in express server. The NODE_ENV environment variable specifies the environment in which an application is running (usually, development or production).
Jest automatically defines environment variable NODE_ENV as test (see https://jestjs.io/docs/environment-variables), as you can confirm from your error message: console.
You can set NODE_ENV as normal and then run forever:
NODE_ENV=production forever [flags] start app.js [app_flags]
The initial NODE_ENV
will be preserved when the server restarts - behaviour that was fixed in this issue:
https://github.com/nodejitsu/forever/issues/116
Older versions of forever can use the following command line format:
NODE_ENV=production forever [flags] app.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With