Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Share On Stumbleupon
Contact us
Hide Buttons

Find the environment variables of a nodejs process in linux

If you have an active nodejs process run­ning on your sys­tem, the eas­i­est way to check what envi­ron­ment vari­ables it is using can be done in 2 sim­ple steps.

  1. Iden­tify the process id of your nodejs app
pe -ef | grep node
  1. Use the PID you found in the above step in the fol­low­ing command
sudo cat /proc/PID/environ | tr \0 \n

The above com­mand spits out a large bunch of key-valye pairs. You can always grep it for the vari­ables you are inter­ested in. e.g.

sudo cat /proc/PID/environ | tr \0 \n | grep NODE_ENV

To check the envi­ron­ment vari­ables from within the code itself, sim­ply log the value of the vari­able process.env any­where in your code.

Ryan Sukale

Ryan is just a regular guy next door trying to manage his life and finances.

You may also like...