Wednesday 7 June 2017

Why does Node not read the env var of the current shell? [duplicate]

This question already has an answer here:

As you can see below, I set an environment variable FOO, but when I execute console.log on the next line, it's undefined. If I set it on the same line where I execture console.log, it is present. Why is the behaviour 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



via Yang Shun

No comments:

Post a Comment