Reputation: 302
Variables are setted in .bashrc
. I can see them on terminal $echo MY_VAR
. Also I can see them on Node.js
shell process.env.MY_VAR
. But I can't see it in my Express App.
file.js
console.log("My var: "+process.env.MY_VAR);
shows: 'My var'
Thanks in advance
Upvotes: 1
Views: 863
Reputation: 13985
.bashrc
is executed when you start a terminal session which is a child of current user session.
So... the user sessions outside the terminal have no idea about anything in .bashrc
.
Now... your node console runs inside the user session of current terminal.
So... if you run a js
script outside a terminal session, it runs in with a new copy of user's session.
So... you will need to create your variables in .bash_profile
which is executed on user login... and everything there is effective for whole user session.
Upvotes: 1