nodejs / docker-node

Official Docker Image for Node.js :whale: :turtle: :rocket:
https://hub.docker.com/_/node/
MIT License
8.26k stars 1.97k forks source link

Can't run npm 8.11.0 on Openshift/OKD #1736

Open KingKunn opened 2 years ago

KingKunn commented 2 years ago

Environment

Expected Behavior

npm can be executed on OKD/Openshift without root permissions

Current Behavior

Built Node16 application can't be started on OKD/Openshift platform, as npm binary or related folder/file permissions do not have enough privileges?

Possible Solution

Steps to Reproduce

Using latest node:16-alpine, node:16-bullseye-slim images to build and run node application. Application runs on local docker container, but when deploying to OKD/Openshift... then container will crash-loop as npm command is not working properly - no output - blank row

Output in Container:

/usr/src/app $ node -v
v16.15.1
/usr/src/app $ npm -v

/usr/src/app $ npm --help

/usr/src/app $ env
...
NODE_VERSION=16.15.1
YARN_VERSION=1.22.19
...

/usr/src/app $ whoami
whoami: unknown uid 1000250000

npm command works on OKD4 when granting root permissions to the container, but this can't be used for security reasons.

Additional Information

Probably this is not my platform/image issue

xitox97 commented 2 years ago

Having this issue as well. npm command returning nothing. Downgrade to different node version then only can uses npm. Do you have any solution?

soulchild commented 2 years ago

This is most likely related to https://github.com/nodejs/docker-node/issues/1734 and https://github.com/npm/cli/issues/4996

kavana-14 commented 5 months ago

will it work on npm 9.5.1, i'm having issue with cache directory The issue arises because npm is trying to use /.npm as its cache directory, which typically requires root permissions. I'm try to create a react app on openshift, but after deployment when I rsh into my container shell and execute the npm start command i'm getting the error /.npm EACCESS. How to solve it . The npm cache directory is set to a location where the user has appropriate permissions, avoiding permission issues.

npm: 9.5.1 Node.js: 18.16.0 OS Name: ubuntu 22.04 #7572