[英]Your cache folder contains root-owned files
Trying to run npm ci on a git deployment branch for my website but receiving the following error;尝试在我的网站的 git 部署分支上运行 npm ci 但收到以下错误;
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /home/storm/.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 1010:1010 "/home/storm/.npm"
I tried running the command it suggests but this doesn't work because there's no such file or directory of "/home/storm/.npm"我尝试运行它建议的命令,但这不起作用,因为没有“/home/storm/.npm”这样的文件或目录
I can't find any answers online!我在网上找不到任何答案! Please help请帮忙
I had this issue and this command worked for me:我遇到了这个问题,这个命令对我有用:
sudo npm cache clean --force
If this issue sill occured try:如果出现此问题,请尝试:
sudo chown -R 1010:1010 "/home/storm/.npm"
Good Luck;-) I hope it works for You.祝你好运;-) 我希望它对你有用。 Watch out for typos..注意错别字。。
There are multiple ways to solve the described issue.有多种方法可以解决所描述的问题。 It depends on how you run npm.这取决于您如何运行 npm。
Option 1: Adapt the access rights on the npm cache files / folder.选项 1:调整 npm 缓存文件/文件夹的访问权限。 Just run the suggested command where 'storm' is your user name and '1010' are your user ID and group ID.只需运行建议的命令,其中“storm”是您的用户名,“1010”是您的用户 ID 和组 ID。 (User ID and group ID sometimes differ.) (用户 ID 和组 ID 有时不同。)
sudo chown -R 1010:1010 "/home/storm/.npm"
Option 2: Remove the npm cache by running the following command:选项 2:通过运行以下命令删除 npm 缓存:
sudo npm cache clean --force
Option 3: Instruct npm to user another directory for caching (avoid using the default npm cache folder).选项 3:指示 npm 使用另一个目录进行缓存(避免使用默认的 npm 缓存文件夹)。 Run the following command before running npm.在运行 npm 之前运行以下命令。
export npm_config_cache=/path/to/cache
In my case I ran yarn / npm in a CI/CD pipeline on a Jenkins agent and faced the same issue.就我而言,我在 Jenkins 代理的 CI/CD 管道中运行了 yarn / npm 并遇到了同样的问题。 Option 3 worked for me.选项 3 对我有用。 I adapted my pipeline and replaced the command我调整了我的管道并替换了命令
gradle testAndCoverageWithYarn
with和
export npm_config_cache=npm-cache && gradle testAndCoverageWithYarn
(The gradle task testAndCoverageWithYarn
calls yarn / npm.) (gradle 任务testAndCoverageWithYarn
调用 yarn / npm。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.