1

I want to read all shell environment variables in Node.js.There is a similar answer.But I find process.env cannot read customize variables.

enter image description here enter image description here

as you can see ,process.env does not include some variables such as JAVA_HOME NVM_DIR.

How to get them?

I can see two ways:

  • read /etc/profile and ~/.bash_profile then calculate what variables user set .

  • or to call shell command env in nodejs.

But there are too complex. Is there a simple way to get them?

Shuai Li
  • 2,426
  • 4
  • 24
  • 43

0 Answers0