I'm having some trouble accessing an environmental variable that I created on a linux server.
I set up the variable permanently by adding: export VAR_NAME=value
Into the /etc/environment file.
The variable appears when I use the printenv
command but when I start the server using PM2 it doesn't exist when calling process.env.VAR_NAME
.
I've tried restarting the machine, and restarting bash, and restarting the pm2 processes themselves multiple times. It seems like some instance of something needs to be restarted, because from my understanding what I wrote into the /etc/environment file gets executed on start up, so the variable isn't technically permanent, making a reboot not really do anything.
Any information on what instance needs to be restarted would help, or a different way of doing this entirely is good.
Edit
Calling process.env
in the node app doesn't come up as undefined, I see all the variables listed from the app, but the variable I created isnt listed there. but it is listed when I call from the terminal