I am trying to set a global environment variable out of my node.js app.
The goals are:
- When restarting the APP, the environment variable should still be set
- When opening a new shell, it should be usable
- If possible: When rebooting, same as 1.
- It should work on Linux, Mac OS X (and needs an alternate SET command for windows)
Here is what I did:
var setEnv = require('child_process')
.spawn('export GLOBALVARNAME='+my.value,{
stdio: 'inherit',
env: process.env
});
But this causes in
{ [Error: spawn export GLOBALVARNAME=foobar ENOENT]
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn export GLOBALVARNAME=foobar',
path: 'export GLOBALVARNAME=foobar',
spawnargs: [] }
I didn't test this on Windows, but on Mac OS X (and Linux) the right command on bash is export GLOBALVARNAME=value
. For Windows the right command should be SET GLOBALVARNAME=value
- isn't it ?
So the main question is: Whats going wrong with the manual working export GLOBALVARNAME=foobar
?
ENOENT
check out #19903328 – Stole