Repository navigation
os.userInfo throws if no username in docker container #25714
Description
Activity
I think the behavior is correct. A documentation PR would be welcome though.
I guess it throws right here - https://github.com/nodejs/node/blob/master/lib/os.js#L253 ?
It does not seem like it ever gets to the next line to throw the generic error with empty context.
Edit: Or it actually mutates the
ctxobject and that's how the detailed message gets printed?- addedosIssues and PRs related to the os subsystem.Issues and PRs related to the os subsystem.docIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.
on Jan 26, 2019 - added a commit that references this issue
on Feb 3, 2019 Hi @raido even-though I am running node:12.0.0 on docker I still get the same error? Is there anything else I need to do to resolve this issue ?
I posted the question on stackoverflow as well but no luck with it yet https://stackoverflow.com/questions/61961485/a-system-error-occurred-uv-os-get-passwd-returned-enoent-no-such-file-or-direc?noredirect=1#comment109603079_61961485Maybe you could use this package: https://github.com/sindresorhus/username?
It has fallback logic for missing username case: sindresorhus/username#22
many thanks @raido what do you mean exactly by that. instead of which package I should used that? I am trying to do ember build that's where I get this error.
Does you app happen to use
ember-cli-cjs-transformpackage? - rwjblue/ember-cli-cjs-transform#123no I don't have that specific package, The only package I found in my project that references uv_os_get_passwd , is in node-gyp . It seems in the latest version of it ( v 5.1.1) this issue is somehow addressed nodejs/node-gyp@c4002de, but updating it to that version still not resolving the issue :( . Is there an workaround that I can use within jenkins to fix this issue? I am using jenkins Pipeline and I have simply :
agent { docker { image 'node:12' args "-v ${env.JENKINS_HOME}:/workspace" reuseNode true } }it turned out all I needed to do was adding docker volumne mapping from /etc/passwd to /etc/passwd. like this :
agent { docker { image 'node:12' args "-v /etc/passwd:/etc/passwd" reuseNode true } }- added a commit that references this issue
on Jul 27, 2026
Original issue opened here: sindresorhus/username#21
It turns out that running a script with
docker runwith--userflag set, then user actually has no$HOMEorusername. This in turn causes following error:uv_os_get_passwd returned ENOENT (no such file or directory)ifos.userInfo()is accessed.Some people have resorted to try catch blocks:
https://github.com/moleculerjs/moleculer/pull/396/files#diff-38423b3db1f1c2a43666c7ad898ba126R45
But is is not documented that
os.userInfo()ever throws - https://nodejs.org/dist/latest-v10.x/docs/api/os.html#os_os_userinfo_options