5

I am trying to install the dependencies from docker file with command RUN npm ci. But I am getting the following error Conflicting peer dependencies. Fix the upstream dependency conflict, or retry this command with --force, or --legacy-peer-deps to accept an incorrect (and potentially broken) dependency resolution.. In my local project I have overcome this issue while running npm install --force. How I can fix this inside the docker while building and running this command RUN npm ci.

As I have understood npm ci will look it either from the package-lock.json or npm-shrinkwrap.json. But still facing this issue. Cannot figure it out what is causing this.

JN_newbie
  • 5,492
  • 14
  • 59
  • 97
  • Can you fix the dependencies (without a "force" option) in your non-Docker development environment, commit the `package.json` and `package-lock.json`/`yarn.lock` files to source control, then rebuild your Docker images with the correct lock file? – David Maze Jun 07 '22 at 16:39
  • @DavidMaze in my non-Docker development environment I am also facing this issue (without a "force" option) – JN_newbie Jun 07 '22 at 16:43
  • @DavidMaze without using --force option in my non-Docker development environment I am getting ```Could not resolve dependency: Fix the upstream dependency conflict, or retry this command with --force, or --legacy-peer-deps to accept an incorrect (and potentially broken) dependency resolution.``` – JN_newbie Jun 07 '22 at 16:45
  • For now I have fixed it with installing the dependencies with npm version to 6. Looks like I need to workout to update the rest of the dependencies to make it work without --force if npm version is >6 – JN_newbie Jun 09 '22 at 08:51

3 Answers3

4

They introduce a breaking changes in npm@8.6 (yes! a minor version bump, with a major breaking changes).

The update changes the behavior of package installation, both from npm install and npm ci.

Previously, the npm ci command would blindly install whatever was in the lock file. AS IS, it will validates both the package-lock.json and package.json is in a consistent state.

You could read more about the issue here: github.com/npm/cli/issues/4998, github.com/npm/cli/issues/5113, and github.com/npm/cli/issues/4664

IronGeek
  • 4,764
  • 25
  • 27
0

I also started to get this error on pipe. What is interesting I always have had peer dependency conflict but it was only appearing with npm install. The best option is to run script with flag --legacy-peer-deps it will skip checking peer dependency. Peer dependency should be installed manually in package.json.

KrisJuris
  • 3
  • 3
0

npm i --force

solved my problem

Note : I got : added 482 packages, and audited 483 packages in 3m Some issues need review, and may require choosing a different dependency.

shaza
  • 37
  • 11