Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing environment variables to node.js using pm2

I am trying to pass some arguments to my Express application which is run by pm2. There wasn't any hint in their documentation to do so, but apparently it's possible to pass some EV to your node application like SOME_STUFF=xxx pm2 start app.js.

like image 315
Yar Avatar asked Nov 11 '15 18:11

Yar


People also ask

How do I set an environment variable for Node modules?

By default, the installer uses the Node. js distribution in C:\Program Files\nodejs. The installer should set the C:\Program Files\nodejs\bin directory in window's PATH environment variable. Restart any open command prompts for the change to take effect.


1 Answers

Note - after updating environment variables in your environment, you must do the following:

pm2 restart all --update-env

ask me how I know...

Edit: also look for a .env file in the node source directory...

like image 70
JEPrice Avatar answered Oct 11 '22 22:10

JEPrice