-
-
Couldn't load subscription status.
- Fork 33.6k
Description
- Version: Since Node 8.0.0. (tested in Node 7.9, Node 8.0.0 and Node 8.2.1)
- Platform: Windows 10 version 1703 x64 using a shell (cmd.exe or git-bash) in ConEmu
Problem description
When executing a process which spawns a child process, which in turn creates another child process, the empty environment variables are passed through as 'undefined' (the string literal, NOT an absent value). If you than for example do an npm install command from that child process, bad things happen:
npm WARN invalid config access=undefined
npm WARN invalid config also=undefined
npm WARN invalid config https-proxy=undefined
npm WARN invalid config Must be a full url with \'http://\'
npm WARN onload-script at Function.Module._resolveFilename (module.js:485:15)
npm WARN onload-script { Error: Cannot find module \'undefined\'
To my knowledge: this only happens in ConEmu, a popular console emulator on Windows. When i downgrade to node 7.9, this problem does not occur.
Steps to reproduce
I created a small github repo to reproduce the problem.
- On windows 10: install ConEmu: https://conemu.github.io/
- Clone this repo
git clone [email protected]:nicojs/reproduce-conemu-child-process-environment-bug.git - run
npm install. - run
npm test
This test spawns a child process, which in turn starts a new child process which logs the process.env to console. The tests verifies that npm_config_onload_script (one of the env variables) is set to ''.
Actual results
When ran from within ConEmu: the test failes
- the env should contain "npm_config_onload_script":
Error: "npm_config_onload_script": "undefined"!"
The test also prints the environment variables to screen. You can see a lot of "undefined" values (the string literal, not an absent value).
For example: "npm_config_onload_script": "undefined",
Expected results
If ran from cmd or git-bash using mintty directly (or on a POSIX environment): the test passes
√ should contain "npm_config_onload_script"
If you now look at the environment variables on screen, you don't see the "undefined" values. Just empty strings.
For example: "npm_config_onload_script": "",
I reported this issue to ConEmu first, but the developer pointed out to me that this seems to be regression in node. See the discussion with Maximus5 here: ConEmu/ConEmu#1209

