'Why can't I perform conditionals on environment variables in a node.js application

When I execute this node.js application...

if(process.env.ENV_ARG === "someValue") {
    console.log("conditional works...");
} else {
    console.log(`ENV_ARG => ${process.env.ENV_ARG}`);
}

with the following script...

  "scripts": {
    "dev": "SET ENV_ARG=someValue && node index.js"
  },

the output is:

ENV_ARG => someValue 

I can't understand why the if statement evaluates to false.
When the contents of process.env.ENV_ARG are logged in the else-block, they should be accessible for the if statement above...at least I thought so...

Thanks in advance



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source