为什么在Gitlab CI/CD管道上的Docker中出现“不允许跨设备链接"错误? [英] Why am I getting a 'cross-device link not permitted' error in Docker on Gitlab CI/CD pipeline?
本文介绍了为什么在Gitlab CI/CD管道上的Docker中出现“不允许跨设备链接"错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试删除node_modules文件夹,但是仍然出现错误.一切正常,但突然开始抛出此错误.
I tried deleting the node_modules folder, but I'm still getting the error. It was working fine, but suddenly has started throwing this error.
这是一个React应用,如果有帮助的话.
It's a react app, if that helps.
Docker文件
## Stage 0, "builder", based on Node.js, to build and compile the frontend
# base image
FROM node:alpine as builder
# set working directory
WORKDIR /app
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
## add app
COPY . /app
# delete node modules to fix discrepancies
RUN rm -rf node_modules/
#RUN npm install && npm audit fix && npm audit fix --force && npm install
RUN npm install -g npm@7.0.3 && npm install && npm audit fix
RUN npm run build
## Stage 1, "deployer", use nginx to deploy the code
## start app
FROM nginx:alpine
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /app/build /usr/share/nginx/html/
RUN rm /etc/nginx/conf.d/default.conf
COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf
控制台错误
npm notice
npm notice New patch version of npm available! 7.0.2 -> 7.0.3
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.0.3>
npm notice Run `npm install -g npm@7.0.3` to update!
npm notice
npm ERR! code EXDEV
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/npm
npm ERR! dest /usr/local/lib/node_modules/.npm-i9nnxROI
npm ERR! errno -18
npm ERR! EXDEV: cross-device link not permitted, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-10-23T16_47_42_554Z-debug.log
The command '/bin/sh -c npm install -g npm@7.0.3 && npm install && npm audit fix' returned a non-zero code: 238
推荐答案
我遇到了同样的问题.由于您的基本映像是节点,因此npm应该已经被全局安装.无需运行 npm install -g npm@7.0.3
,之后仍然能够执行所有与npm相关的项目.
I ran into the same issue. Since your base image is node, npm should already be globally installed. There is no need to run npm install -g npm@7.0.3
and still be able to execute all npm related items afterwards.
这篇关于为什么在Gitlab CI/CD管道上的Docker中出现“不允许跨设备链接"错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文