So I have an env variable defined in my ZSH terminal like this in my .zshrc
file:
export VAR=FOO
So when I do $ echo $VAR
in ZSH it prints FOO
. However, if I open a node
terminal and does process.env.VAR
it prints undefined
. Tried even rebooting the system and tried on Mac and Linux. Any thoughts?
CodePudding user response:
It was just a stupid error I didn't realize before.
I had in my .zshrc
file
VAR=FOO
instead of
export VAR=FOO
I was sure I wrote it with the export
, but it wasn't the case. Adding the export
fixed the issue. Thank you @Shachar297 to make me double-check my config file.
CodePudding user response:
Use
printenv
To get a list of all the environment variables. Or
printenv | grep VAR
To see your exact exported variable.
Also, nake sure you start the nodejs in the same terminal as exporting the variable.