Be the first user to complete this post

  • 0
Add to List

Find the environment variables of a nodejs process in linux

If you have an active nodejs process running on your system, the easiest way to check what environment variables it is using can be done in 2 simple steps.

  1. Identify the process id of your nodejs app
pe -ef | grep node
  1. Use the PID you found in the above step in the following command
sudo cat /proc/PID/environ | tr \0 \n
The above command spits out a large bunch of key-valye pairs. You can always grep it for the variables you are interested in. e.g.
sudo cat /proc/PID/environ | tr \0 \n | grep NODE_ENV
To check the environment variables from within the code itself, simply log the value of the variable process.env anywhere in your code.

Also Read:

  1. Understanding routers in express 4.0 - Visually
  2. Understanding semver versioning for your nodejs packages
  3. What is an npmignore file and what is it used for
  4. Organizing your expressjs routes in separate files.
  5. Configure The 'script' tag In package.json To Run Multiple Commands
  6. Resolved - sudo npm command not found
  7. Setup passportjs for local authentication and authorization using expressjs
  8. nodejs: generate uuid / guid