Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

When installing a package using the node:8-alpine docker image on AWS using an M5 instance type NPM fails with "Error: could not get uid/gid" #20861

Open
nathanburrell opened this issue Jun 1, 2018 · 1 comment

Comments

@nathanburrell
Copy link

nathanburrell commented Jun 1, 2018

I'm opening this issue because:

  • [ x] npm is crashing.
  • [x ] npm is producing incorrect or undesirable behavior.

What's going wrong?

node 8 alpine image does not appear to work on AWS m5 instances.

Error: could not get uid/gid
[ 'nobody', 0 ]
at /usr/local/lib/node_modules/npm/node_modules/uid-number/uid-number.js:37:16
at ChildProcess.exithandler (child_process.js:282:5)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
TypeError: Cannot read property 'get' of undefined
at errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205:18)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:83:20
at cb (/usr/local/lib/node_modules/npm/lib/npm.js:224:22)
at /usr/local/lib/node_modules/npm/lib/npm.js:262:24
at /usr/local/lib/node_modules/npm/lib/config/core.js:81:7
at Array.forEach ()
at /usr/local/lib/node_modules/npm/lib/config/core.js:80:13
at f (/usr/local/lib/node_modules/npm/node_modules/once/once.js:25:25)
at afterExtras (/usr/local/lib/node_modules/npm/lib/config/core.js:178:20)
at Conf. (/usr/local/lib/node_modules/npm/lib/config/core.js:236:22)
at /usr/local/lib/node_modules/npm/node_modules/uid-number/uid-number.js:39:14
at ChildProcess.exithandler (child_process.js:282:5)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205
if (npm.config.get('json')) {
^
TypeError: Cannot read property 'get' of undefined
at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205:18)
at emitOne (events.js:116:13)
at process.emit (events.js:211:7)
at process._fatalException (bootstrap_node.js:378:26)

How can the CLI team reproduce the problem?

On EC2 with a new m5 instance type with ubuntu 16.04 and docker 1.13.1 the below command fails with the error described above.

docker container run -it node:8-alpine /bin/sh -c "npm install -g nsp"

On EC2 with a new m5 instance type with ubuntu 16.04 and docker 1.13.1 the below command passes.

docker container run -it node:8 /bin/sh -c "npm install -g nsp"

On EC2 with an old m4 instance type with ubuntu 16.04 and docker 1.13.1 the below command passes.

docker container run -it node:8-alpine /bin/sh -c "npm install -g nsp"

On EC2 with an old m4 instance type with ubuntu 16.04 and docker 1.13.1 the below command passes.

docker container run -it node:8 /bin/sh -c "npm install -g nsp"

This leads me to believe that node on alpine (and maybe due to libmusl) is having a compatiblity issue with amazons new nitro virtualization stack.

http://www.brendangregg.com/blog/2017-11-29/aws-ec2-virtualization-2017.html
https://aws.amazon.com/ec2/instance-types/m5/

This was (we have since changed our instance types back to m4) affecting customers of the product I work on Bitucket Pipelines.

https://bitbucket.org/site/master/issues/16334/pipelines-failing-with-could-not-get-uid

@ccheshire
Copy link

I ran into the same issue after we upgraded to an m5 instance,
found a solution at npm/uid-number#3 (comment)

so I added
RUN npm config set unsafe-perm true to my Dockerfile before the npm install and everything works again

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants