I am trying to set a global environment variable from my node.js. application
Objectives:
- When restarting APP, the environment variable should still be set
- When opening a new shell, you should use it.
- If possible: upon reboot, as 1.
- It should work on Linux, Mac OS X (and requires an alternative 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 it causes in
{ [Error: spawn export GLOBALVARNAME=foobar ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn export GLOBALVARNAME=foobar', path: 'export GLOBALVARNAME=foobar', spawnargs: [] }
I have not tested this on Windows, but on Mac OS X (and Linux) the correct bash command is export GLOBALVARNAME=value . For Windows, the correct command should be SET GLOBALVARNAME=value - right?
So, the main question: what happens to manual work export GLOBALVARNAME=foobar ?
user3984802
source share