Skip to content
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

[BUG] <EACCES permissions errors when installing packages, npm is trying to use /.npm as its cache directory, which typically requires root permission > #7572

Closed
2 tasks done
kavana-14 opened this issue May 30, 2024 · 4 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps

Comments

@kavana-14
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /.npm
npm ERR! errno -13
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 1007390000:0 "/.npm"

npm ERR! Log files were not written due to an error writing to the directory: /.npm/_logs
npm ERR! You can rerun the command with --loglevel=verbose to see the logs in your terminal

Expected Behavior

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.

Steps To Reproduce

  1. In this environment...
  2. With this config...
  3. Run '...'
  4. See error...

Environment

  • npm: 9.5.1
  • Node.js: 18.16.0
  • OS Name: ubuntu 22.04
  • System Model Name: Windows 10
  • npm config:
$ npm config ls
; node bin location = /usr/local/bin/node
; node version = v18.16.0
; npm local prefix = /home/node/app
; npm version = 9.5.1
; cwd = /home/node/app
; HOME = /
; Run `npm config ls -l` to show all defaults
@kavana-14 kavana-14 added Bug thing that needs fixing Needs Triage needs review for next steps labels May 30, 2024
@milaninfy
Copy link
Contributor

milaninfy commented May 30, 2024

@kavana-14 npm will have appropriate access if it got installed correctly. If you want to change location of cache you can use --cache flag in your command to specify different location for caching. Checkout https://docs.npmjs.com/cli/v10/using-npm/config#cache

also from error log you can try changing permission of that directory to fix.

npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 1007390000:0 "/.npm"

@kavana-14
Copy link
Author

kavana-14 commented May 31, 2024

@milaninfy I tried to fix the issue from the error logs, included that command inside the Dockerfile, but got the issue as below,

Step 11/14 : RUN chown -R 1007390000:0 "/.npm"
---> Running in 6dbe5b2a8315

chown: cannot access '/.npm': No such file or directory
The command '/bin/sh -c chown -R 1007390000:0 "/.npm"' returned a non-zero code: 1

I logged into the container shell and check the existence of /.npm directory

$ ls -l /.npm
ls: cannot access '/.npm': No such file or directory
$
$ ls -l ~/.npm
ls: cannot access '//.npm': No such file or directory

> oc rsh client-56975c6c4-x454j
$ npm config get cache
/.npm

I think /.npm reside inside the cache directory

@milaninfy
Copy link
Contributor

@kavana-14 What happens when you set cache to different location does it work for you ?,
npm config set cache ./another/location or you can specify the cache in .npmrc.

@kavana-14
Copy link
Author

@milaninfy, thank you, setting the cache to different location solved my issue, but the problem is with my browser. I can be able to expose the service and see the web page in my chrome but not possible in Internet Explorer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps
Projects
None yet
Development

No branches or pull requests

2 participants