简体   繁体   English

您的缓存文件夹包含根拥有的文件

[英]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.

相关问题 Jenkins 构建问题 - npm 错误! 您的缓存文件夹包含 root 拥有的文件 - Jenkins build issue - npm ERR! Your cache folder contains root-owned files npm 安装总是给出“您的缓存文件夹包含根拥有的文件,由于 npm 以前版本的 npm 中的错误,该错误已得到解决。” - npm install always gives 'Your cache folder contains root-owned files, due to a bug in npm previous versions of npm which has since been addressed.' 错误“由于 npm ERR 中的错​​误,您的缓存文件夹包含根拥有的文件!之前版本的 npm 已得到解决” - Error "Your cache folder contains root-owned files, due to a bug in npm ERR! previous versions of npm which has since been addressed" 错误“您的缓存文件夹包含根拥有的文件,由于以前版本的 npm 中的错误”而“npx create-react-app example_app” - Error "Your cache folder contains root-owned files, due to a bug in previous versions of npm" while "npx create-react-app example_app" 更新或修改nodejs服务器中root拥有的文件 - Update or modify files owned by root from nodejs server npm 安装错误并且无法更改 root 拥有的文件的所有权 - npm install error and unable to change ownership of root owned files NodeJs在没有root的情况下访问root拥有的文件 - NodeJs access root owned file without root 如何在nodejs的根文件夹之外上传文件? - How to upload files outside root folder in nodejs? Neutrinojs / vue项目:从根文件夹导入vue文件/模板 - Neutrinojs/vue project: Importing vue files/templates from root folder dist /文件夹中的JS文件与root文件夹中的JS文件有什么区别? - What is the difference between JS files in dist/ folder and the one in root?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM