Can't read my environment variable in my Node.js app

后端 未结 4 673
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-02 15:10

I am on Ubuntu 12.04 and I\'m just learning about environment variables. I am trying to read a custom variable from within my application but it always shows up as undefin

4条回答
  •  星月不相逢
    2021-02-02 15:25

    You need to export shell variables in order to make them available to processes you execute in your shell.

    Compare the output of this command:

    FOO=bar; bash -c 'echo $FOO'
    

    with the output of this:

    export FOO=bar; bash -c 'echo $FOO'
    

提交回复
热议问题