Npm install doesn't complete inside docker container

Expected behavior

npm install should install all the modules and end with ‘ok’. Running npm install on the host system using the same package.json completes successfully

Actual behavior

npm ERR! Linux 4.4.9-moby
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v6.2.0
npm ERR! npm  v3.8.9
npm ERR! path /src/node_modules/acorn/bin/acorn
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod

npm ERR! enoent ENOENT: no such file or directory, chmod '/src/node_modules/acorn/bin/acorn'
npm ERR! enoent ENOENT: no such file or directory, chmod '/src/node_modules/acorn/bin/acorn'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     /src/npm-debug.log

Or, sometimes:

npm ERR! Linux 4.4.9-moby
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v5.11.0
npm ERR! npm  v3.8.6
npm ERR! path /src/node_modules/body-parser/node_modules
npm ERR! code EEXIST
npm ERR! errno -17
npm ERR! syscall mkdir

npm ERR! EEXIST: file already exists, mkdir '/src/node_modules/body-parser/node_modules'
npm ERR! File exists: /src/node_modules/body-parser/node_modules
npm ERR! Move it away, and try again.

npm ERR! Please include the following file with any support request:
npm ERR!     /src/npm-debug.log

Information

OS X: version 10.11.4 (build: 15E65)
Docker.app: version v1.11.1-beta12
Running diagnostic tests:
[OK] Moby booted
[OK] driver.amd64-linux
[OK] vmnetd
[OK] osxfs
[OK] db
[OK] slirp
[OK] menubar
[OK] environment
[OK] Docker
[OK] VT-x
Docker logs are being collected into /tmp/20160518-211729.tar.gz
Most specific failure is: No error was detected
Your unique id is: 76C69662-2BBB-495B-84DC-CD632C441871

Version 1.11.1-beta12 (build: 7528)
OSX 10.11.4 (15E65)

Steps to reproduce the behavior

Create a new dockerfile as follows:

FROM node:6.2.0-slim

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get -yq update && apt-get -yq install git bzip2 automake build-essential

RUN npm install -g --silent ember-cli@2.5.0 bower@1.7.1 phantomjs@1.9.19

# Add an ember user because bower doesn't like being root
RUN adduser --disabled-password --gecos "" ember && \
  echo "ember ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

RUN \
  git clone https://github.com/facebook/watchman.git &&\
  cd watchman &&\
  git checkout v3.5.0 &&\
  ./autogen.sh &&\
  ./configure &&\
  make &&\
  make install

ENV LANG en_GB.UTF-8

RUN mkdir /src && chown ember:ember /src
WORKDIR /src

# Always run as the yeoman user
USER ember

CMD [ "ember", "server" ]

Build it

docker build -t docker-ember .

Create the following package.json:

{
  "name": "src",
  "version": "0.0.0",
  "description": "Small description for src goes here",
  "private": true,
  "directories": {
    "doc": "doc",
    "test": "tests"
  },
  "scripts": {
    "build": "ember build",
    "start": "ember server",
    "test": "ember test"
  },
  "repository": "",
  "engines": {
    "node": ">= 0.10.0"
  },
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "active-model-adapter": "2.1.1",
    "broccoli-asset-rev": "^2.4.2",
    "ember-ajax": "0.7.1",
    "ember-cli": "2.5.0",
    "ember-cli-app-version": "^1.0.0",
    "ember-cli-babel": "^5.1.6",
    "ember-cli-bootstrap-sassy": "0.5.3",
    "ember-cli-dependency-checker": "^1.2.0",
    "ember-cli-htmlbars": "^1.0.3",
    "ember-cli-htmlbars-inline-precompile": "^0.3.1",
    "ember-cli-inject-live-reload": "^1.4.0",
    "ember-cli-jshint": "^1.0.0",
    "ember-cli-mirage": "0.1.13",
    "ember-cli-moment-shim": "1.1.0",
    "ember-cli-qunit": "^1.4.0",
    "ember-cli-release": "0.2.8",
    "ember-cli-sass": "5.3.1",
    "ember-cli-sri": "^2.1.0",
    "ember-cli-uglify": "^1.2.0",
    "ember-data": "^2.5.0",
    "ember-export-application-global": "^1.0.5",
    "ember-load-initializers": "^0.5.1",
    "ember-moment": "6.1.0",
    "ember-resolver": "^2.0.3",
    "ember-route-action-helper": "0.3.1",
    "ember-truth-helpers": "1.2.0",
    "loader.js": "^4.0.1"
  }
}

Run npm install:

docker run -it --rm  -v $(pwd):/src docker-ember npm install

Following @davefinster’s advice, I ran docker run -it --rm -v $(pwd):/src docker-ember to enter the container, copied the package.json file to my users home directory and re-ran npm install.

Sure enough, the install process finished without any glitches. So I guess that suggests a problem with the osxfs mounted folder? Anyway, hope that helps…

I had similar issues with trying to upgrade npm. Ended up finding an issue logged against it on github https://github.com/npm/npm/issues/9863

Appeared to work when I added the following to the Dockerfile (taken from one of the comments on that issue):

RUN cd $(npm root -g)/npm \
 && npm install fs-extra \
 && sed -i -e s/graceful-fs/fs-extra/ -e s/fs\.rename/fs.move/ ./lib/utils/rename.js

Hi @misterdai

I tried that this mornign but still receive the following (after removing node_modules and re-running npm install):

npm ERR! Linux 4.4.9-moby
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v5.11.1
npm ERR! npm  v3.8.6
npm ERR! path /src/node_modules/body-parser/node_modules
npm ERR! code EEXIST
npm ERR! errno -17
npm ERR! syscall mkdir

npm ERR! EEXIST: file already exists, mkdir '/src/node_modules/body-parser/node_modules'
npm ERR! File exists: /src/node_modules/body-parser/node_modules
npm ERR! Move it away, and try again.

Thanks for your efforts, anyhow

I’m having the same issue trying to run npm install with any package inside the osxfs mounted volume, fix suggested above doesn’t seem to do anything unfortunately.

I’m seeing the same issue. Also can’t seem to copy files from other places in the container to the mounted file system.

Same here. I just downloaded and tried the new Docker for Mac Beta. It was going great until i hit the same snag:


npm ERR! Linux 4.4.9-moby
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v6.2.0
npm ERR! npm  v3.8.9
npm ERR! path /app/node_modules/anymatch/node_modules
npm ERR! code EEXIST
npm ERR! errno -17
npm ERR! syscall mkdir

npm ERR! EEXIST: file already exists, mkdir '/app/node_modules/anymatch/node_modules'
npm ERR! File exists: /app/node_modules/anymatch/node_modules
npm ERR! Move it away, and try again.

npm ERR! Please include the following file with any support request:
npm ERR!     /app/npm-debug.log

Exactly the same problem here. Tried both node:6 and node:5.11.1, it’s definitely caused by mounting the volume unfortunately. Can probably be worked around by mounting the application code in as a volume, and not mounting node-modules itself, but this is quite annoying unfortunately :frowning:

I’m running into this too. I’ve opened an issue on the npm side. Not sure if that’s the appropriate place.

^^^ prefix with https. Won’t let me post a link.

This is the Makefile based solution I’m using:

https://forums.docker.com/t/unable-to-perform-any-npm-install-inside-a-osxfs-mounted-directory/12590/13?u=davefinster

Thats for Alpine Linux (installing gcc and friends) but easily adjusted

I’m getting the same issue with npm when using the local filesystem as a volume. It install properly otherwise.

I got word that this should be fixed when Docker For Mac beta 13 lands.

Bug fixed in beta 13: “Fixed major regression in Beta 12 with ENOENT, ENOTEMPY, and other spurious errors after a directory rename. This manifested as npm install failure and other directory traversal issues.
Fixed temporary file ENOENT errors”

But I still have the same error after upgrade.

This has been fixed for me.

AMAZING, yes this is fixed for me too :slight_smile:

Thanks team.

This issue has been fixed for me as well with the latest software update (1.11.1-beta13 build: 7975)

I correct myself, the fix IS working.
Thanks to the team!

I still have this on beta14. At least the symptom, don’t know if it could be another problem.

I’m having troubles doing an npm install

I get essentially this:

npm ERR! Linux 4.4.14-moby
npm ERR! argv “/usr/local/bin/node” “/usr/local/bin/npm” “install” "gulp-uglify"
npm ERR! node v4.4.7
npm ERR! npm v2.15.8
npm ERR! code EIO
npm ERR! errno -5
npm ERR! syscall fstat

npm ERR! EIO: i/o error, fstat
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! https://github.com/npm/npm/issues

I’m running this command:

docker run -v $PWD:/src -w /src -it node:argon npm install

i’m on the latest Beta17.

I’m also on v1.12.0-rc2-beta17 and still get this error. It seems to always happen when installing Phantomjs.

npm ERR! Linux 4.4.14-moby
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--unsafe-perm"
npm ERR! node v0.12.9
npm ERR! npm  v2.14.9
npm ERR! code EIO
npm ERR! errno -5
npm ERR! EIO, fstat
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR!     /Users/lyndonh/Sites/mobile/npm-debug.log