How can one retrieve an updated environment variable once a node script is already running?
Consider the following gulp task. How can you update the environment variable Z (i.e., from some other script running on the system) so that the function outputs different values after it's running?
As is, environment variables set elsewhere are ignored and the function always outputs 'undefined'.
gulp.task('z', function () {
var z;
setInterval(function(){
z = process.env.Z;
console.log('Value of Z is: ' + z);
}, 1000);
});
Running Windows 7. I have tried both set
and setx
but nothing will persist into the running node script. I wouldn't think this is possible since you generally can't pass environment variables between command prompts without re-launching them (and using setx
). But then again SO users are special and I've been surprised before. Is this even possible?