I'm trying pass an environment variable to Node.js with PowerShell like this way:
C:\Users\everton\my-project> $env:MY_VAR = 8000 node index.js   But I get an error in PowerShell:
Token 'node' unexpected expression or statement
Set environmental variable MY_VAR first and run your app like this:
C:\Users\everton\my-project> $env:MY_VAR="8000" ; node index.js   You can access environmental variable MY_VAR inside index.js by
process.env.MY_VAR   Note: PowerShell doesn't directly support command-scoped environment variables. The above command sets the environment variable for that PowerShell session.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With