-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EACCES: permission denied, open '/usr/local/lib/node_modules/npm/bin/npm-cli.js' #1262
Comments
I am also new to docker and I have similar problem with Dockerfile:
i get
and also there is this issue:
|
I just tested this locally and it doesn't seem to be a problem with the image itself. Running |
That sadly didn't work for me. I'm sure I must be doing something wrong here, since it seems weird that I can't access any of the files at all... I'm using the same build as binoysarker.
|
Did you follow that step when installing docker? https://stackoverflow.com/a/55255557 |
I had just been running I suspected it might have something to do with installing via snap, so I purged the installation and reinstalled using the main ubuntu instructions. Now running Still not sure why things had been working for months until just now, but I'm at least up and running again. Thanks for your patience Laurent! |
same |
@binoysarker can you try the suggested fix? |
@binoysarker in the Dockerfile, all "RUN" commands (listed after "USER node") will be executed on behalf of a "node" user.
So at first, i recommend to change all you "COPY" commands in this way:
|
The first builds on docker hub all failed. The error we were getting was ``` [91m ERR! Error: EACCES: permission denied, open '/home/node/package.json' npm ERR! [Error: EACCES: permission denied, open '/home/node/package.json'] { npm ERR!�[0m [91m errno: -13, npm ERR! code: 'EACCES', npm �[0m [91mERR! syscall: 'open', npm ERR! path: '/home/node/package.json' ... �[91m The operation was rejected by your operating system. npm ERR! It is likely you do not have the permissions to access this file as the current user npm ERR!�[0m �[91m npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. �[0m �[91m �[0m �[91mnpm ERR! A complete log of this run can be found in: npm ERR!�[0m �[91m /home/node/.npm/_logs/2021-02-18T09_51_29_644Z-debug.log �[0m Removing intermediate container 04acee56b734 The command '/bin/sh -c npm install' returned a non-zero code: 243 ``` Some searching of the net indicated that the problem is because the `node` user that is provided in the base image and which we set as the main user does not own the `package.json` files we copy into the image. It's best practise not to leave the user as `root` in a Docker image, nor to run `npm install` as `root`. We now understand the reason the `node` user is not the owner of the files is because all `COPY` commands in a Dockerfile are carried out as the `root` user. The suggested fix is to include [chown](https://en.wikipedia.org/wiki/Chown) within your copy statement to ensure once the files are available the non-root user is made the owner. - nodejs/docker-node#1262 (comment) - https://stackoverflow.com/a/44766666/6117745
Hello sir i am new to docker, i am using ubuntu budgie 20.04 my docker version is
Docker version 18.09.9, build 1752eb3
i have install docker using snap package manager and the path is like this
/snap/bin/docker.machine /snap/bin/docker.compose /snap/bin/docker /snap/bin/docker.help
I am learning docker by making a single nodejs express app with docker. Here is my Dockerfile
here is my app.js file
When i start to build an image from this dockerfile i get this error
Please tell me how can i fix this.
Thanks.
The text was updated successfully, but these errors were encountered: