I need to execute the following command for production environment:
NODE_ENV=production node app.js
I tried passing it as a command under Configueration:
I get the following error in the logs:
sh: NODE_ENV=prod node app.js: command not found
I also tried:
NODE_ENV=prod //
error: sh: NODE_ENV=prod: command not found
NODE_ENV=prod app.js //
error: sh: NODE_ENV=prod app.js: command not found
What's the best way to execute the following command when launching the app on ELB:
NODE_ENV=production node app.js
You don't need to set the node command manually. Elastic Beanstalk attempts to start app.js
, then server.js
, and then npm start
in that order. You can set the value of NODE_ENV
in the "Environment Properties" section under "Configuration".
As others have mentioned you can manually add them by going to Configuration -> Software -> Environment properties.
A second way to do this is to add a .ebextensions/environment.config
file.
.ebextensions
at the root of your project. environment.config
within .ebextensions
. Example of environment.config
:
option_settings:
- option_name: NODE_ENV
value: production
You need to use the "Environment Properties" Not the node command.
Key: NODE_ENV
Value: production
I would just set NODE_ENV
in Environment Properties under the same configuration area. You can also set this in your .ebextensions
config.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.