'Docker: npm run start causing error, EACCES: permission denied, open '/home/node/node_modules/.cache/.eslintcache
I have created a react app and trying to run it over the docker container with volumes (mapping content inside the container with outside files), everything was working fine earlier but now facing an issue as shared. Can anyone help me with that? This is a permission issue but doesn't know how to resolve that. root user has access of node_modules folder. How to give access to node user ?
My docker file
FROM node:alpine
USER node
WORKDIR '/home/node'
COPY package.json .
RUN npm install
COPY . .
CMD ["npm", "run", "start"]
Commands used:
docker build -t frontend -f Dockerfile.dev .
docker run -p 3000:3000 -v /home/node/node_modules -v $(pwd):/home/node frontend:latest
Access in container:
~ $ ls -l
total 1488
-rw-rw-r-- 1 node node 124 Jun 20 08:37 Dockerfile.dev
-rw-rw-r-- 1 node node 3369 Jun 17 18:25 README.md
drwxr-xr-x 3 node node 4096 Jun 17 18:45 build
-rw-rw-r-- 1 node node 230 Jun 20 06:56 docker-compose.yml
drwxrwxr-x 1041 root root 36864 Jun 20 19:15 node_modules
-rw-rw-r-- 1 node node 1457680 Jun 18 18:28 package-lock.json
-rw-rw-r-- 1 node node 811 Jun 17 18:26 package.json
drwxrwxr-x 2 node node 4096 Jun 17 18:25 public
drwxrwxr-x 2 node node 4096 Jun 17 18:25 src
Solution 1:[1]
This file is not a very important file that can cause major application failures if removed. its just a cache file created by external dependencies using eslinter. You can just safely remove by running
sudo rm /home/$USER/path-to-your-project/node_modules/.cache/.eslintcache
Solution 2:[2]
Create a .eslintignore file and put * in it.
Solution 3:[3]
if you'r running docker-compose, changing the Dockerfile when npm installing worked for me after a lot of investigation
RUN cd /usr/src/app && npm install
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Andrew Mititi |
| Solution 2 | Omar Elweshy |
| Solution 3 |


