Why is Node not reading the env var of the current shell?
As you can see below, I am setting an environment variable FOO
, but when I execute console.log
on the next line, this undefined
. If I install it on the same line where I execute console.log
it is present. Why behavior as such?
$ FOO="123"
$ echo $FOO
123
$ node -e "console.log(process.env.FOO)"
undefined
$ FOO="123" node -e "console.log(process.env.FOO)"
123
Node version: 6.6.0
+3
source to share