how does NODE_ENV work
<p>in packages.json I see scripts set to be run under specific environments .</p>

<pre><code>"scripts": {
    "prod": "node_modules/.bin/gulp build; NODE_ENV=production webpack --config webpack.config.prod.js --display-error-details",
    "bower": "node_modules/.bin/bower",
    "test": "NODE_ENV=test jest" , .....
</code></pre>

<p>my questions are : </p>

<p>1-where are these environments declared ? </p>

<p>2-what is the difference between <code>NODE_ENV=test</code> and <code>NODE_ENV=development</code> ?</p>

<p>3-how does npm understand them and how can it tell what is my current environment?</p>

<p>4- can you explain differences between how and when to run the mentioned scripts </p>