Why can't I set NODE_ENV to undefined?
<p>I'm trying to implement a test where my code works correctly in different Node.js environments, by changing and testing the value of variable <code>NODE_ENV</code>.</p>

<p>What I'm stuck with, is trying to understand why the following code:</p>

<pre><code>process.env.NODE_ENV = undefined;

var test = process.env.NODE_ENV || 'empty';

console.log(test);
</code></pre>

<p>outputs <code>undefined</code> instead of <code>empty</code>.</p>

<p>Is that some JavaScript or Node.js feature that I'm missing here?</p>

<p>Tested under Node.js versions: 0.10.47, 4.6.1 and 6.9.1</p>

<hr>

<h3>update</h3>

<p>As a work-around for this specific case I had to do the following:</p>

<pre><code>delete process.env.NODE_ENV; // now it is undefined
</code></pre>