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

npm error ERESOLVE unable to resolve dependency tree | Could not resolve dependency | dependency conflict eslin & eslint-config-next #1467

Open
sofiane-abou-abderrahim opened this issue Oct 21, 2024 · 8 comments
Labels

Comments

@sofiane-abou-abderrahim

I've just used the npm-check-updates package in my Next.js 14 application to update Next.js and all my packages to the latest versions.

In my terminal, I ran the following commands:

  1. npm install -g npm-check-updates
  2. ncu
  3. ncu -u

At this stage, everything worked well, but when I ran:
4. npm install, I got this error below in my terminal:

$ npm install
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: nextjs14@0.1.0
npm error Found: eslint@9.13.0
npm error node_modules/eslint
npm error   dev eslint@"^9" from the root project
npm error
npm error Could not resolve dependency:
npm error peer eslint@"^7.23.0 || ^8.0.0" from eslint-config-next@14.2.15
npm error node_modules/eslint-config-next
npm error   dev eslint-config-next@"14.2.15" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error C:\Users\DELL\AppData\Local\npm-cache\_logs\2024-10-21T07_18_58_317Z-eresolve-report.txt
npm error A complete log of this run can be found in: C:\Users\DELL\AppData\Local\npm-cache\_logs\2024-10-21T07_18_58_317Z-debug-0.log
@raineorshine
Copy link
Owner

Peer dependency checks are opt-in because they add a significant performance cost. Try reverting and see if this works instead:

ncu --peer -u

@sofiane-abou-abderrahim
Copy link
Author

I have this error:

$ ncu --peer -u
Upgrading C:\Users\DELL\Desktop\cliquedigitale_nextjs14\package.json
[====================] 43/43 100%
[==------------------] 4/43 9%(node:17496) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
[====================] 43/43 100%
[====================] 21/21 100%
TypeError: Invalid comparator: insiders
    at e.parse (C:\Users\DELL\AppData\Roaming\nvm\v21.0.0\node_modules\npm-check-updates\build\index.js:59:19019)
    at new e (C:\Users\DELL\AppData\Roaming\nvm\v21.0.0\node_modules\npm-check-updates\build\index.js:59:18822)
    at C:\Users\DELL\AppData\Roaming\nvm\v21.0.0\node_modules\npm-check-updates\build\index.js:59:14939
    at Array.map (<anonymous>)
    at e.parseRange (C:\Users\DELL\AppData\Roaming\nvm\v21.0.0\node_modules\npm-check-updates\build\index.js:59:14931)
    at C:\Users\DELL\AppData\Roaming\nvm\v21.0.0\node_modules\npm-check-updates\build\index.js:59:13614
    at Array.map (<anonymous>)
    at new e (C:\Users\DELL\AppData\Roaming\nvm\v21.0.0\node_modules\npm-check-updates\build\index.js:59:13602)
    at Object.JI [as intersects] (C:\Users\DELL\AppData\Roaming\nvm\v21.0.0\node_modules\npm-check-updates\build\index.js:59:22271)  
    at C:\Users\DELL\AppData\Roaming\nvm\v21.0.0\node_modules\npm-check-updates\build\index.js:510:3677
Unhandled Rejection! This is a bug and should be reported: https://github.com/raineorshine/npm-check-updates/issues

1 similar comment
@sofiane-abou-abderrahim
Copy link
Author

I have this error:

$ ncu --peer -u
Upgrading C:\Users\DELL\Desktop\cliquedigitale_nextjs14\package.json
[====================] 43/43 100%
[==------------------] 4/43 9%(node:17496) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
[====================] 43/43 100%
[====================] 21/21 100%
TypeError: Invalid comparator: insiders
    at e.parse (C:\Users\DELL\AppData\Roaming\nvm\v21.0.0\node_modules\npm-check-updates\build\index.js:59:19019)
    at new e (C:\Users\DELL\AppData\Roaming\nvm\v21.0.0\node_modules\npm-check-updates\build\index.js:59:18822)
    at C:\Users\DELL\AppData\Roaming\nvm\v21.0.0\node_modules\npm-check-updates\build\index.js:59:14939
    at Array.map (<anonymous>)
    at e.parseRange (C:\Users\DELL\AppData\Roaming\nvm\v21.0.0\node_modules\npm-check-updates\build\index.js:59:14931)
    at C:\Users\DELL\AppData\Roaming\nvm\v21.0.0\node_modules\npm-check-updates\build\index.js:59:13614
    at Array.map (<anonymous>)
    at new e (C:\Users\DELL\AppData\Roaming\nvm\v21.0.0\node_modules\npm-check-updates\build\index.js:59:13602)
    at Object.JI [as intersects] (C:\Users\DELL\AppData\Roaming\nvm\v21.0.0\node_modules\npm-check-updates\build\index.js:59:22271)  
    at C:\Users\DELL\AppData\Roaming\nvm\v21.0.0\node_modules\npm-check-updates\build\index.js:510:3677
Unhandled Rejection! This is a bug and should be reported: https://github.com/raineorshine/npm-check-updates/issues

@raineorshine
Copy link
Owner

Please share your package.json dependency declarations and I will try to reproduce.

@sofiane-abou-abderrahim
Copy link
Author

sofiane-abou-abderrahim commented Oct 26, 2024

Here is my package.json file:

{
  "name": "nextjs14-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@clerk/localizations": "^2.4.8",
    "@clerk/nextjs": "^5.2.4",
    "@hookform/resolvers": "^3.9.0",
    "@radix-ui/react-dialog": "^1.1.1",
    "@radix-ui/react-icons": "^1.3.0",
    "@radix-ui/react-label": "^2.1.0",
    "@radix-ui/react-menubar": "^1.1.1",
    "@radix-ui/react-select": "^2.1.1",
    "@radix-ui/react-slot": "^1.1.0",
    "@radix-ui/react-tabs": "^1.1.0",
    "@radix-ui/react-toast": "^1.2.2",
    "@tailwindcss/typography": "^0.5.13",
    "@tinymce/tinymce-react": "^5.1.1",
    "class-variance-authority": "^0.7.0",
    "clsx": "^2.1.1",
    "eslint-config-prettier": "^9.1.0",
    "eslint-config-standard": "^17.1.0",
    "eslint-plugin-tailwindcss": "^3.17.4",
    "html-entities": "^2.5.2",
    "html-react-parser": "^5.1.12",
    "lucide-react": "^0.414.0",
    "mongodb": "^6.8.0",
    "mongoose": "^8.5.1",
    "next": "14.2.4",
    "prettier": "^3.3.2",
    "prismjs": "^1.29.0",
    "query-string": "^9.1.0",
    "react": "^18",
    "react-dom": "^18",
    "react-hook-form": "^7.52.1",
    "svix": "^1.25.0",
    "tailwind-merge": "^2.4.0",
    "tailwindcss-animate": "^1.0.7",
    "zod": "^3.23.8"
  },
  "devDependencies": {
    "@types/node": "^20",
    "@types/prismjs": "^1.26.4",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "eslint": "^8",
    "eslint-config-next": "14.2.4",
    "postcss": "^8",
    "tailwindcss": "^3.4.1",
    "typescript": "^5"
  }
}

@sofiane-abou-abderrahim
Copy link
Author

@raineorshine
Copy link
Owner

I was able to reproduce with this minimal package.json:

{
  "name": "nextjs14-app",
  "version": "0.1.0",
  "dependencies": {
    "@tailwindcss/typography": "^0.5.13"
  },
  "devDependencies": {
    "tailwindcss": "^3.4.1"
  }
}

The culprit is this interesting peerDependencies declaration in @tailwindcss/typography:

  "peerDependencies": {
    "tailwindcss": ">=3.0.0 || insiders || >=4.0.0-alpha.20"
  },

https://github.com/tailwindlabs/tailwindcss-typography/blob/199a0c6f66dc9568614601e5deebff131f697ac7/package.json#L32-L34

insiders apparently refers to a dist-tag. Unfortunately, specifying tags in a dependency spec is not compatible with https://github.com/npm/node-semver. Specifically, validRange and satisfies return false, and intersects throws an invalid comparator (which you were graced with).

The format >=3.0.0 || insiders || >=4.0.0-alpha.20 requires another level of parsing to substitute dist-tags. It must either be a new syntax or one that is rarely used, as I have never seen it before. It is doable to add support if there is an intrepid contributor that would like to take it on. I don't have the time now unfortunately.

In the mean time, I have added logic to detect "invalid" peer dependency specs and skip them and output a reasonably useful explanation. That should at least allow npm-check-updates to run without error, and then you can decide how you want to handle the enterprising dependency. Published in v17.1.9.

TLDR: npm-check-updates does not yet support the peer dependency spec that @tailwindcss/typography uses.

@sofiane-abou-abderrahim
Copy link
Author

I run npm-check-updates and I didn't get any error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants