title: How can I check if an environment variable is set in Node.js?
body: <p>I would like to check if an environment variable is set in my <a href="https://www.npmjs.com/package/express" rel="noreferrer">Express JS</a> server and perform different operations depending on whether or not it is set.</p>
  
  <p>I've tried this:</p>
  
  <pre><code>if(process.env.MYKEY !== 'undefined'){
      console.log('It is set!');
  } else {
      console.log('No set!');
  }
  </code></pre>
  
  <p>I'm testing without the <code>process.env.MYKEY</code> but the console prints "It is set".</p>