coreybutler / node-windows

Windows support for Node.JS scripts (daemons, eventlog, UAC, etc).
Other
2.78k stars 357 forks source link

Not having any luck with environment variables #291

Closed toggledbits closed 2 years ago

toggledbits commented 2 years ago

I can't get environment variables to be set, or least, they aren't showing up in process.env in my application. I have tried both the array and object versions of the env key.

My code/fragment, pretty much straight from the example code:

    // rp is the application path and is known to be defined (and tested for existence before this point)
    let ev = { REACTOR_HOME: rp, NODE_PATH: rp };
    if ( TZ ) {
        ev.TZ = TZ;
    }
    console.log( "env", ev );
    var svc = new Service({
      name: 'Reactor',
      description: 'Reactor (Multi-System) Service',
      script: ap,
      nodeOptions: [],
      workingDirectory: rp,
      env: ev
    });

The debug/console.log output shows:

env {
  REACTOR_HOME: 'C:\\Users\\toggledbits\\Documents\\MSR',
  NODE_PATH: 'C:\\Users\\toggledbits\\Documents\\MSR',
  TZ: 'America/New_York'
}

When the service starts, it logs that process.env is completely and totally empty. None of the variables passed is set.

Any clue what I'm not catching a clue of my own on here?

toggledbits commented 2 years ago

Yes, I need reading practice. Missed the subtlety of the name/value keys when specifying the pairing. Nothing to see here, folks... move along... move along.