我需要安装依赖项以在CI/CD上构建前端。
文档文件:
FROM node:18.12.1
enter code here
ENV CI="true"
WORKDIR /workdir
COPY package.json package-lock.json /workdir/
RUN npm ci
package.json
{
"name": "v2",
...
"dependencies": {
"formik": "^2.2.9",
"i18next": "^21.9.1",
"lodash": "^4.17.21",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.3.0",
"react-scripts": "5.0.1"
},
"devDependencies": {
"typescript": "^4.9.5"
},
...
}
在容器中,我遇到了这样的错误:
npm ERR! code EUSAGE
npm ERR!
npm ERR! `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
npm ERR!
npm ERR! Invalid: lock file's ajv@6.12.6 does not satisfy ajv@8.12.0
npm ERR! Missing: ajv@6.12.6 from lock file
...
启动本地环境工作正常。如何修复此行为?
我已经尝试删除node_modules
和npm install
2条答案
按热度按时间eyh26e7m1#
我遇到这个问题是因为在我的用户设置(~/.npmrc)中,
legacy-peer-dns
标志被设置为true
。rm5edbpk2#
尝试添加以下
Dockerfile
:如果成功了告诉我。