Jenkins 构建问题 - npm ERR!您的缓存文件夹包含 root 拥有的文件
Jenkins build issue - npm ERR! Your cache folder contains root-owned files
我正在尝试在我的 Jenkins 管道上构建一个小型节点应用程序,它是 运行 在虚拟机中。越过这个错误:
+ npm install
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /.npm
npm ERR! errno EACCES
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 111:120 "/.npm"
运行 sudo chown -R 111:120 "/.npm"
没有帮助,因为它说:
chown: cannot access '/.npm': No such file or directory
并且,根据我的理解,在本地上下文中运行,而问题实际上是从容器的角度来看的。我也尝试在我的 Docker 和 Jenkinsfile 上添加上面的命令,但无济于事。下面是我的 public 回购:
npm install --cache=".YourCustomCacheDirectoryName"
工作得很好,原因是您的 docker 用户不允许写入 /(根目录)
这并不是说 /.npm 中已经存在一个目录,而是您的脚本试图在 / 上创建一个您的用户无法访问的目录
你可以把
agent {
docker {
image 'node:latest'
args '-u root:root'
}
}
或者只告诉 npm 使用您的自定义缓存目录
据我所知,只需更新 npm 版本并删除整个项目就可以了。
我正在尝试在我的 Jenkins 管道上构建一个小型节点应用程序,它是 运行 在虚拟机中。越过这个错误:
+ npm install
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /.npm
npm ERR! errno EACCES
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 111:120 "/.npm"
运行 sudo chown -R 111:120 "/.npm"
没有帮助,因为它说:
chown: cannot access '/.npm': No such file or directory
并且,根据我的理解,在本地上下文中运行,而问题实际上是从容器的角度来看的。我也尝试在我的 Docker 和 Jenkinsfile 上添加上面的命令,但无济于事。下面是我的 public 回购:
npm install --cache=".YourCustomCacheDirectoryName"
工作得很好,原因是您的 docker 用户不允许写入 /(根目录) 这并不是说 /.npm 中已经存在一个目录,而是您的脚本试图在 / 上创建一个您的用户无法访问的目录 你可以把
agent {
docker {
image 'node:latest'
args '-u root:root'
}
}
或者只告诉 npm 使用您的自定义缓存目录
据我所知,只需更新 npm 版本并删除整个项目就可以了。