Skip to content

[BUG] npm install --force fails for peerOptional conflicts #2504

Closed
npm/arborist
#228
@targos

Description

@targos

Current Behavior:

Run npm install --force fails instead of ignoring upstream dependency conflict

Expected Behavior:

It should print a warning and continue with the installation.

Steps To Reproduce:

git clone https://github.com/targos/npm-force-peer-dep.git
cd npm-force-peer-dep
npm install --force

Output:

npm WARN using --force Recommended protections disabled.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: typescript@4.1.3
npm ERR! node_modules/typescript
npm ERR!   dev typescript@"^4.1.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional typescript@"^3.2.1" from react-scripts@4.0.1
npm ERR! node_modules/react-scripts
npm ERR!   dev react-scripts@"^4.0.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Targos\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm resolution error report
# npm resolution error report

2021-01-18T07:56:28.615Z

Found: typescript@4.1.3
node_modules/typescript
  dev typescript@"^4.1.3" from the root project

Could not resolve dependency:
peerOptional typescript@"^3.2.1" from react-scripts@4.0.1
node_modules/react-scripts
  dev react-scripts@"^4.0.1" from the root project

Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

Raw JSON explanation object:

{
  "code": "ERESOLVE",
  "current": {
    "name": "typescript",
    "version": "4.1.3",
    "location": "node_modules/typescript",
    "dependents": [
      {
        "type": "dev",
        "name": "typescript",
        "spec": "^4.1.3",
        "from": {
          "location": "D:\\Git\\targos\\npm-force-peer-dep"
        }
      }
    ]
  },
  "edge": {
    "type": "peerOptional",
    "name": "typescript",
    "spec": "^3.2.1",
    "error": "INVALID",
    "from": {
      "name": "react-scripts",
      "version": "4.0.1",
      "location": "node_modules/react-scripts",
      "dependents": [
        {
          "type": "dev",
          "name": "react-scripts",
          "spec": "^4.0.1",
          "from": {
            "location": "D:\\Git\\targos\\npm-force-peer-dep"
          }
        }
      ]
    }
  },
  "peerConflict": null,
  "strictPeerDeps": false,
  "force": true
}

Environment:

  • OS: Windows 10
  • Node: 15.6.0
  • npm: 7.4.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingPriority 1high priority issueRelease 7.xwork is associated with a specific npm 7 releaseplatform:windowsis Windows-specific

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions