next-auth: NextJS 13 Dependency Error

Environment

  System:
    OS: Linux 5.10 Pengwin 11 (bullseye)
    CPU: (12) x64 AMD Ryzen 5 2600 Six-Core Processor
    Memory: 12.19 GB / 15.61 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 8.15.0 - ~/.nvm/versions/node/v16.17.0/bin/npm
  npmPackages:
    next: 13.0.0 => 13.0.0
    react: 18.2.0 => 18.2.0

Reproduction URL

none

Describe the issue

I tried to upgrade my existing project to NextJS 13, but got blocker from next-auth package. The error as follows

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: next13@0.1.0
npm ERR! Found: next@13.0.0
npm ERR! node_modules/next
npm ERR!   next@"13.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer next@"^12.2.5" from next-auth@4.15.0
npm ERR! node_modules/next-auth
npm ERR!   next-auth@"*" 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!

This also happens when installing on newly created project.

How to reproduce

  1. Create new NextJS project using npm

    npx create-next-app nextjs13
    
  2. Change directory to the newly created project

    cd nextjs13
    
  3. Try to install next-auth

    npm install next-auth
    

Then got the error mentioned above

Expected behavior

next-auth can be used on NextJS 13 projects

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 21
  • Comments: 16 (6 by maintainers)

Most upvoted comments

Adding "overrides": { "next-auth": { "next": "13.0.0" } } to package.json will allow installing without --force or --legacy-peer-deps

Apologize, yes I can confirm this is an issue, rolling out a fix now 🙌

@ThangHuuVu, would you mind sharing your npm version? npm install fails because next-auth@4.15.0 literally requires next@12:

https://github.com/nextauthjs/next-auth/blob/a787efc6bec26067c75ce22b2f213ddec6fbfa0d/packages/next-auth/package.json#L80-L81

% node -v
v16.18.0

% npm -v
8.19.2

% npm install next-auth
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: nextjs13@0.1.0
npm ERR! Found: next@13.0.0
npm ERR! node_modules/next
npm ERR!   next@"13.0.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer next@"^12.2.5" from next-auth@4.15.0
npm ERR! node_modules/next-auth
npm ERR!   next-auth@"*" 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/home/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/home/.npm/_logs/2022-10-26T15_42_37_953Z-debug-0.log

@balazsorban44 @ThangHuuVu any ideas when the update will make it to npm?

@balazsorban44 thank you! do you have understanding when this fix could be released?

Same issue, next@13 is not supported by next-auth@4.15.0. Note: you’ll have to delete node_modules and package-lock.json if previously you used npm i --force.

I tried the reproduction steps but didn’t get any errors 🤔 I also tried to pull our example repo and install, as our example repo has specified "next": "latest" dependencies, I also didn’t get any errors 🤷‍♂️

When fix release?

@ThangHuuVu it’s working on exact 13, but not on canary, more details: https://github.com/nextauthjs/next-auth/pull/5657#issuecomment-1295162710

Everything works fine for me using yarn but I am getting this warning:

warning " > next-auth@4.15.0" has incorrect peer dependency “next@^12.2.5”.

It may also be helpful to make sure npx is using the latest create-next-app version:

npx create-next-app@13 nextjs13