[solved] Problem when running `npm install` inside Docker (npm ERR! code ENOENT)

Error message:

npm ERR! path /app/node_modules/npm/node_modules/ansistyles
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/app/node_modules/npm/node_modules/ansistyles' -> '/app/node_modules/npm/node_modules/.ansistyles.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-08-29T08_17_27_580Z-debug.log
By @mustafa on Wed 29 Aug 2018 |
Tags docker npm node

Responses:

Offer your help. Be nice!

@mustafa
1

This issue could have many causes based on my research.
For me, it was copying my /app/node_modules directory from my host into the Docker image.

I solved it by adding /shop/node_modules to my .dockerignore and building again with --no-cache

Login to leave a response!