Inlining the env works SOMETHING=hello node -e "console.log(process.env.SOMETHING)", but I want node to read the environment variables from the spawning shell.
The following code will print hello (note that echo can read the environment)
SOMETHING=hello
echo $SOMETHING
However the following code prints undefined:
SOMETHING=hello
node -e "console.log(process.env.SOMETHING)"
Why can't node read the shell environment? Can I make it read that somehow?
SOMETHING, but not an environment variable. By default, shell variables don't go into the environment.FOO=x; bash -c 'echo ${FOO:-undefined}'prints undefined.echo $SOMETHING, theechocommand is not getting the value ofSOMETHINGfrom the environment, the shell is expanding the variable and then passing the result toecho.