`npm install` error that isn't reproducing in a local Docker container


I have an npm install at https://circleci.com/gh/jeffcharles/number-switcher-4000/6, that fails with a EINVAL when trying to chown ‘/root/number-switcher-4000/node_modules/.staging/react-dom-ddae5caa’. The build is using the node:8.0.0 docker image which ships with npm 5. The weird thing is when I run npm install using the same docker image locally (after deleting the node_modules directory) with my project volume mounted into it, the npm install operation succeeds. Another weird thing is that the npm install operation succeeds if I use a docker container with a Node 7.10.0. I need npm 5 though for the lock file.

After ssh’ing in, the log file ends with:

4817 verbose stack TypeError: Cannot read property 'write' of null
4817 verbose stack     at Zlib.callback (zlib.js:455:34)
4818 verbose cwd /root/number-switcher-4000
4819 verbose Linux 3.13.0-119-generic
4820 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
4821 verbose node v8.0.0
4822 verbose npm  v5.0.0
4823 error Cannot read property 'write' of null
4824 verbose exit [ 1, true ]

After removing the node_modules directory and trying npm install again I get:

5220 verbose stack Error: EINVAL: invalid argument, chown '/root/number-switcher-4000/node_modules/.staging/react-dom-ddae5caa'
5221 verbose cwd /root/number-switcher-4000
5222 verbose Linux 3.13.0-119-generic
5223 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
5224 verbose node v8.0.0
5225 verbose npm  v5.0.0
5226 error path /root/number-switcher-4000/node_modules/.staging/react-dom-ddae5caa
5227 error code EINVAL
5228 error errno -22
5229 error syscall chown
5230 error EINVAL: invalid argument, chown '/root/number-switcher-4000/node_modules/.staging/react-dom-ddae5caa'
5231 verbose exit [ -22, true ]

Why is my build only failing on CircleCI and not locally? Is there anything I can do locally to reproduce the build failure?


It might just be an error in that new container; it is the :latest and has the chance to be unstable;



Running an npm install inside the node:8.0.0 container works. Just not on CircleCI.


Having the exact same issue, using tag 8.0.0 or 8.0. Not working on CircleCI only.


I can reproduce this, but I doubt it’s a bug with the 2.0 platform itself. https://circleci.com/gh/ryanwohara/test-2.0/322#config/containers/0


Any ETA on this? It’s preventing us from upgrading to node 8.


Not at this time.


Thank you. Please let us know.



Building of Docker images based upon 8.0

It works fine to use circleci/node:8


I’m having the same issue. Work around for us, we’re staying with Yarn which will still allow you to use Node 8.


Same issue but I’m installing node in my python container. One data point that seems relevant is that I think all of the containers in question here are Debian based. Mine is Jessie and I think the base Node one is Wheezy.

FROM python:2.7.13

RUN apt-get update
RUN apt-get -y install gcc libsasl2-dev lib32z1-dev libldap2-dev
RUN curl -sL https://deb.nodesource.com/setup_8.x -o install_node.sh; sh install_node.sh
RUN apt-get install -y nodejs


I’m having the exact same issue. I can successfully run npm install in my docker image, but it fails on Circle CI. My image is based on ubuntu:16.04.


We are also seeing this problem. I can run npm install inside docker locally but not in circle. I have also tried to run it in your circleci cli tool locally and npm install works fine.

The ability to run inside docker, with the safety it gives you that if it works on one machine it works on the next is our biggest selling point to use circle. Especially circle 2. This kind of behaviour is quite scary so I do hope you can figure it out and fix it soon.


Any updates?


I have the same issue (circleci 2.0, npm 5.0.3)
and it occurs only in circleci, not in local (circleci build).

based on docker:17.05.0-ce-git:

apk add nodejs
npm install -g npm@5.0.3


Same problem here using a custom node:8 image (circleci version 2 config). The issue is that we cannot switch to yarn because of cordova using npm behing the scene. I think our best option is to downgrade NPM version to 4.x.x for cordova to use it, and use yarn for our own module management (to keep the benefits of the lock file).

It looks like this is temporary fixing it for now (until npm@5) is supported to CircleCI:

  - run:
     name: Install latest version 4 of NPM
     command: npm i -g npm@latest-4


I’m seeing the error with node:8.1.3 but if I switch to the alpine image (node:8.1.2-alpine) it seems to work fine:

Step 7 : RUN npm install --silent
—> Running in 2509fccfc3f5
added 505 packages in 18.34s


Thanks @mmcgarr, so node:8.1.3-alpine comes with yarn, so using yarn to install npm@latest (as of this posting, npm@5.1.0) has resolved the issue for now…

RUN yarn global add npm@latest


I ran into this when upgrading to node 8.1.4 from 6.11.0, was able to build fine locally but CircleCI was throwing the previously mentioned errors.

One solution/workaround I found to this problem is to create a directory in the container that is owned by a specific user and then switching to that user.


FROM node:8.1.4
RUN install -d -o node -g node /myapp
WORKDIR /myapp
USER node

the install command is just a fancy mkdir & chown, then set that as the WORKDIR, set the container to that USER… solved the issue for me.

Hope that helps.

Node.js npm install devDependencies