Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ERESOLVE unable to resolve dependency tree #3113

Closed
abdusamadtv opened this issue Apr 21, 2021 · 7 comments
Closed

[BUG] ERESOLVE unable to resolve dependency tree #3113

abdusamadtv opened this issue Apr 21, 2021 · 7 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release

Comments

@abdusamadtv
Copy link

abdusamadtv commented Apr 21, 2021

Current Behavior:

Getting ERESOLVE unable to resolve dependency tree error while installing dependencies

Expected Behavior:

Successful installation of dependencies

Steps To Reproduce:

rm -rf node_modules package-lock.json

Environment:

  • OS: macOS Big Sur 11.2.3 (20D91)
  • Node: 16.0.0
  • npm: 7.10.0

Error

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: [email protected]
npm ERR! node_modules/pg
npm ERR!   pg@"^8.0.2" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peerOptional pg@"^7.18.2" from [email protected]
npm ERR! node_modules/knex
npm ERR!   knex@"^0.20.14" from the root project
npm ERR!   peer knex@"<0.95.0" from [email protected]
npm ERR!   node_modules/objection
npm ERR!     objection@"^2.1.3" 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 /Users/abdusamad/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/abdusamad/.npm/_logs/2021-04-21T05_30_29_351Z-debug.log

package.json

{
  "name": "",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "commonjs",
  "engines": {
    "node": ">=12.16.2"
  },
  "scripts": {
    "migrate": "knex migrate:latest",
    "lint": "eslint ./ --fix",
    "dev": "nodemon src/index.js",
    "start": "node src/index.js",
    "postinstall": "link-module-alias",
    "preinstall": "command -v link-module-alias && link-module-alias clean || true"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "axios": "^0.19.2",
    "bcrypt": "^4.0.1",
    "cron": "^1.8.2",
    "currency-codes": "^2.1.0",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "iconv-lite": "^0.6.2",
    "jsonwebtoken": "^8.5.1",
    "knex": "^0.20.14",
    "link-module-alias": "^1.2.0",
    "moment": "^2.24.0",
    "mongoose": "^5.9.10",
    "morgan": "^1.10.0",
    "nodemon": "^2.0.3",
    "objection": "^2.1.3",
    "oracledb": "^4.2.0",
    "p-limit": "^3.0.2",
    "pg": "^8.0.2",
    "rotating-file-stream": "^2.1.3",
    "uuid": "^7.0.3",
    "xml2js": "^0.4.23"
  },
  "devDependencies": {
    "eslint": "^6.8.0",
    "eslint-config-prettier": "^6.10.1",
    "eslint-plugin-prettier": "^3.1.3",
    "prettier": "^2.0.4"
  },
  "_moduleAliases": {
    "~root": "./"
  }
}
@abdusamadtv abdusamadtv added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Apr 21, 2021
@ljharb
Copy link
Contributor

ljharb commented Apr 21, 2021

The error message tells you the problem: namely, that you depend on pg v8, but the version of knex you're using requires pg 7. This means your dependency graph is invalid.

You need to either downgrade pg to v7, or upgrade knex to a version that peerDepends on pg v8.

@abdusamadtv
Copy link
Author

abdusamadtv commented Apr 21, 2021

The error message tells you the problem: namely, that you depend on pg v8, but the version of knex you're using requires pg 7. This means your dependency graph is invalid.

You need to either downgrade pg to v7, or upgrade knex to a version that peerDepends on pg v8.

Then why does everything work when I switch to Node.js v14.16.1 and npm v6.14.12?

@ljharb
Copy link
Contributor

ljharb commented Apr 21, 2021

It doesn't actually work - it's just that npm 6 doesn't tell you during installs that your dep graph is invalid. Run npm ls, and you'll see it exit nonzero.

When your dep graph is invalid, things might work, but you can't rely on that.

@cdupetit
Copy link

Same problem for me.

@arjunsatyanandaraju
Copy link

I have faced the same issue. As a quick fix, I had to downgrade to npm version 6.

Other solution would be to use '--legacy-peer-deps' flag.

@ljharb
Copy link
Contributor

ljharb commented Apr 22, 2021

The proper fix is to make your dep graph valid. Downgrading to npm 6, or using the legacy flag, just hides that your program (not npm) is broken.

If the peer dep error message isn’t clear to anyone, please post it - I’m happy to decipher it.

@abdusamadtv does fixing the invalid combo with pg help?

@darcyclarke
Copy link
Contributor

As @ljharb has noted, you must resolve the conflict in your peer dependencies to resolve this problem; There's options to work around this (ie. --force or --legacy-peer-deps) as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

5 participants