2
$ setx NODE_TLS_REJECT_UNAUTHORIZED 0

SUCCESS: Specified value was saved.

$ node -e "console.log(process.env.NODE_TLS_REJECT_UNAUTHORIZED); console.dir(process.env.windir);"
undefined
'C:\\WINDOWS'

setx said it worked (value was "saved"). But the node process.env object doesn't contain it. Why is setx wrong?

This didn't work either:

$ set NODE_TLS_REJECT_UNAUTHORIZED=0
$ node -e "console.log(process.env.NODE_TLS_REJECT_UNAUTHORIZED)"
undefined

Incidentally it did work with this command: $env:NODE_TLS_REJECT_UNAUTHORIZED="0"

Related: How can I set NODE_ENV=production on Windows?.

jcollum
  • 43,623
  • 55
  • 191
  • 321
  • Are you starting a new instance of node after setting the variable? (Environment variables on Windows are generally inherited rather than propagated.) – Bill_Stewart Jul 19 '17 at 20:22
  • 1
    To change the current environment ( not the master/persistent environment) simply use `$ENV:NODE_TLS_REJECT_UNAUTHORIZED=0` –  Jul 19 '17 at 21:06
  • @LotPings that's in my post already – jcollum Jul 20 '17 at 14:39
  • @Bill_Stewart that's what `node -e` does, evaluates code in a new node instance – jcollum Jul 20 '17 at 14:40
  • I don't know the details, but if it's not working, perhaps "new instance" != "new process". Environment variables are tied to processes. – Bill_Stewart Jul 20 '17 at 14:42
  • But the new instance inherits it's emvironment from the current process. –  Jul 20 '17 at 14:44
  • Correct, so setting the variable in the current process should be all that's needed. – Bill_Stewart Jul 20 '17 at 16:15

0 Answers0