I call my node.js application with
node index.js a=5
I want to use the value '5' directly as an environment variable in my code like
const myNumber = process.env.a
(like stated here).
If I try the above, 'MyNumber' is undefinded on runtime.
Solution
- Linux:
a=5 node index.js
- Windows (Powershell):
$env:a="5";node index.js