I need to install dependencies to build the frontend on CI/CD.
Dokerfile:
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"
},
...
}
In container I faced with this errors:
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 [email protected] does not satisfy [email protected]
npm ERR! Missing: [email protected] from lock file
...
Start on local environment works fine. How to fix this behavior?
I’ve tried remove node_modules
and npm install
2
Answers
I ran into this problem because in my user settings(~/.npmrc) the
legacy-peer-dns
flag was set totrue
.Try to add the following
Dockerfile
:Let me know if this works.