title: Can't read my environment variable in my Node.js app
body: <p>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 <code>undefined</code>. Here is the code of my test app:</p>
  
  <pre><code>// app.js
  
  console.log('Value: ' + process.env.NODE_ENV);
  </code></pre>
  
  <p>If I run the following commands you will see that the variable has a value:</p>
  
  <pre><code>$ NODE_ENV=production
  $ echo $NODE_ENV
  production
  </code></pre>
  
  <p>I can <code>echo $NODE_ENV</code> all day and it will continue to show me "production", but when I do <code>process.env.NODE_ENV</code> in my Node application it always displays "undefined".</p>
  
  <pre><code>$ node app.js
  Value: undefined
  </code></pre>
  
  <p>Here is the odd part though, if I display another environment variable that I know already exists, say <code>process.env.PATH</code>, then it works.</p>
  
  <pre><code>$ node app.js
  Value: /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
  </code></pre>
  
  <p>Another quirk is that the command <code>printenv list</code> doesn't appear to contain my custom variable <code>NODE_ENV</code> despite the fact that <code>echo $NODE_ENV</code> shows me the correct value. <code>printenv NODE_ENV</code> shows nothing as well, but <code>printenv PATH</code> shows the proper value just as it did when I accessed <code>PATH</code> in my node application.</p>