Weird errors from npm when working in shared folder

Expected behavior

npm to correctly install all modules and dependencies based on package.json content

Actual behavior

npm crashes with random errors about missing files or files already existing like:

npm ERR! Linux 4.4.15-moby
npm ERR! argv "/usr/bin/node" "/usr/sbin/npm" "install"
npm ERR! node v4.4.7
npm ERR! npm  v3.10.5
npm ERR! path /home/app/src/node_modules/browserify/node_modules/.bin
npm ERR! code EEXIST
npm ERR! errno -17
npm ERR! syscall mkdir

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

This happens only while invoking in shared folder. If I use ADD in Dockerfile without mounted volume, it works fine. It also works fine on linux.

I tried latest Docker for Mac stable and latest beta. No difference.

Update: The workaround is to exclude node_modules folder from being shared. I’ve used this method

1 Like

Any update on this? I’m getting the same issue.
Temporary workaround is to execute npm install --no-bin-links until it stops to throw Maximum call stack size exceeded error (2-3 times for me, see https://github.com/npm/npm/issues/10776).

This issue was likely fixed in a Beta 21 hotfix (build 11019). Please try that out and let us know if the problem persists.