Open scooper91 opened 5 years ago
Trying to do npm install as root in a mounted folder caused a lot of problems. Can you check what thw permissions of your $PWD
are?
Interesting - when I run npm i
in the container as the node
user, the package installs fine.
The files are owned by the node
user (in the container) regardless of whether I run the container as root
or node
:
We haven't changed anything from our side, and we didn't used to have any issues. I am unsure what the root cause of the problem is, and why we're seeing this error (especially the difference between mounting a file vs directory).
Is running npm i
as root
something which we shouldn't be able to do?
You can do it but it does lead to all sort of permission mismatch which makes debugging these types of issue very hard.
I should also point out that it's especially problematic with mounted volumes from the host system.
I've encountered the same problem when upgrading our docker-images from node 11 to 12.
First I tried 12.13.0-alpine, then 12.13.0-buster-slim and 12.11.1-buster-slim, all with the same error.
12.9.1-buster-slim finally worked again, and so did 12.9.1-alpine. I've not checked versions in between, but somewhere there must be the problem.
I have what looks like the same issue which started sometime between 12/13 and 12/27 - using node+npm from deb.nodesource.com. It didn't matter which version of node I used (still using 8 for some builds), but it starts in npm 6.11.0 (6.10.3 works fine).
Confirming the issue. Currently using this as a workaround (thanx to @hcomnetworkers !)
FROM node:12.9.1-alpine
....
RUN npm i
....
FROM node:12-alpine
....
COPY --from=0 ...
(assumes that all node-gyp output will be compatible between different minor versions of the node container)
I believe y'all are running into this issue https://github.com/npm/cli/issues/624
A fix is in the latest release of npm https://github.com/npm/cli/releases/tag/v6.13.6
I believe y'all are running into this issue npm/cli#624
A fix is in the latest release of npm https://github.com/npm/cli/releases/tag/v6.13.6
Installing npm that includes v6.13.6 solved the issue for me. Thank you!
Just in case - for those who are on alpinelinux-based containers (comes with official docker image of node-red): as of today, container is built on alpinelinux v3.10. the fix is available only in npm v12.14.1-r0 that is not in v3.10 To get required version, one need to append "@edge http://nl.alpinelinux.org/alpine/edge/main" to /etc/apk/repositories and then install "apk add npm@edge"
Guys, I was having the same problem and maybe/probably because I am too dumb on docker I couldn't figure out how to make npm@edge
version work on my docker image. Finally, I've noticed the ending sentence of @hcomnetworkers which made my day. :heart:
So, if anyone is struggling with that, simply downgrade the version of your Linux alpine image to 12.9.1-alpine
as suggested above, as a workaround, and it should work at least until the image edge version changes are moved to the latest release.
chown root:root -R xxx/bin/npm or chown root:root -R /xxxx
chown root:root -R xxx/bin/npm or chown root:root -R /xxxx
Thanks mate, this answer really help me ###
When trying to install packages from GitHub using
node:12-slim
, we're seeing the following error:This first broke on the morning of the 5th October. It worked fine on the morning of the 4th October.
This only happens when we're mounting a directory - if we just mount the
package.json
, it works fine.I have not tried other node images.
To re-create, create a
package.json
in an empty directory:Create a
Dockerfile
alongside thepackage.json
:From the directory, run:
That errors when trying to create leading directories:
The debug log file shows the following:
When mounting just the
package.json
, it works fine, e.g:Let me know if you need any more information.
Thanks!