vercel / next.js

The React Framework
https://nextjs.org
MIT License
124.8k stars 26.64k forks source link

[Turbopack] [Dev] Error: Could not parse module '/app-router-context.js' with `next-auth` #67998

Closed ThangHuuVu closed 1 month ago

ThangHuuVu commented 1 month ago

Link to the code that reproduces this issue

https://github.com/ThangHuuVu/na-10585

To Reproduce

  1. Pull the reproduction, install the dependencies with pnpm i
  2. Start the dev server, visit http://localhost:3000
  3. Click on "Sign In" button top right corner of the page

Current vs. Expected behavior

Current: The error in the console:

 ✓ Compiled /auth/[...nextauth] in 276ms
 ⨯ Error: Could not parse module '[project]/node_modules/.pnpm/next@15.0.0-canary.75_react-dom@19.0.0-rc.0_react@19.0.0-rc.0__react@19.0.0-rc.0/node_modules/next/dist/server/route-modules/app-route/vendored/contexts/app-router-context.js'
    at Object.<anonymous> (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/ffa4d_next_74bbb3._.js:7997:11)
    at [project]/node_modules/.pnpm/next@15.0.0-canary.75_react-dom@19.0.0-rc.0_react@19.0.0-rc.0__react@19.0.0-rc.0/node_modules/next/dist/server/route-modules/app-route/vendored/contexts/app-router-context.js [app-route] (ecmascript) (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/ffa4d_next_74bbb3._.js:8000:3)
    at instantiateModule (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:561:23)
    at getOrInstantiateModuleFromParent (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:613:12)
    at commonJsRequire (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:146:20)
    at Object.<anonymous> (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/ffa4d_next_74bbb3._.js:8577:40)
    at [project]/node_modules/.pnpm/next@15.0.0-canary.75_react-dom@19.0.0-rc.0_react@19.0.0-rc.0__react@19.0.0-rc.0/node_modules/next/dist/client/components/navigation.js [app-route] (ecmascript) (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/ffa4d_next_74bbb3._.js:8669:3)
    at instantiateModule (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:561:23)
    at getOrInstantiateModuleFromParent (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:613:12)
    at commonJsRequire (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:146:20)
    at Object.<anonymous> (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/ffa4d_next_74bbb3._.js:8672:18)
    at [project]/node_modules/.pnpm/next@15.0.0-canary.75_react-dom@19.0.0-rc.0_react@19.0.0-rc.0__react@19.0.0-rc.0/node_modules/next/navigation.js [app-route] (ecmascript) (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/ffa4d_next_74bbb3._.js:8674:3)
    at instantiateModule (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:561:23)
    at getOrInstantiateModuleFromParent (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:613:12)
    at esmImport (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:132:20)
    at /Users/thangvu/repos/oss/na-10585/.next/server/chunks/node_modules__pnpm_4cc47e._.js:3223:316
    at [project]/node_modules/.pnpm/next-auth@5.0.0-beta.19_@simplewebauthn+server@9.0.3_next@15.0.0-canary.75_react-dom@19.0.0-r_7ztrzzbkevpedyrctofljs75fm/node_modules/next-auth/lib/actions.js [app-route] (ecmascript) (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/node_modules__pnpm_4cc47e._.js:3330:3)
    at instantiateModule (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:561:23)
    at getOrInstantiateModuleFromParent (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:613:12)
    at esmImport (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:132:20)
    at /Users/thangvu/repos/oss/na-10585/.next/server/chunks/node_modules__pnpm_4cc47e._.js:3474:365
    at [project]/node_modules/.pnpm/next-auth@5.0.0-beta.19_@simplewebauthn+server@9.0.3_next@15.0.0-canary.75_react-dom@19.0.0-r_7ztrzzbkevpedyrctofljs75fm/node_modules/next-auth/index.js [app-route] (ecmascript) <module evaluation> (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/node_modules__pnpm_4cc47e._.js:3479:3)
    at instantiateModule (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:561:23)
    at getOrInstantiateModuleFromParent (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:613:12)
    at esmImport (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:132:20)
    at /Users/thangvu/repos/oss/na-10585/.next/server/chunks/[root of the server]__14c334._.js:113:384
    at [project]/auth.ts [app-route] (ecmascript) (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[root of the server]__14c334._.js:160:3)
    at instantiateModule (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:561:23)
    at getOrInstantiateModuleFromParent (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:613:12)
    at esmImport (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:132:20)
    at /Users/thangvu/repos/oss/na-10585/.next/server/chunks/[root of the server]__14c334._.js:168:110
    at [project]/app/auth/[...nextauth]/route.ts [app-route] (ecmascript) (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[root of the server]__14c334._.js:173:3)
    at instantiateModule (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:561:23)
    at getOrInstantiateModuleFromParent (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:613:12)
    at esmImport (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:132:20)
    at /Users/thangvu/repos/oss/na-10585/.next/server/chunks/ffa4d_next_74bbb3._.js:8688:148
    at [project]/node_modules/.pnpm/next@15.0.0-canary.75_react-dom@19.0.0-rc.0_react@19.0.0-rc.0__react@19.0.0-rc.0/node_modules/next/dist/esm/build/templates/app-route.js { INNER_APP_ROUTE => "[project]/app/auth/[...nextauth]/route.ts [app-route] (ecmascript)" } [app-route] (ecmascript) (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/ffa4d_next_74bbb3._.js:8722:3)
    at instantiateModule (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:561:23)
    at instantiateRuntimeModule (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:621:12)
    at Object.getOrInstantiateRuntimeModule (/Users/thangvu/repos/oss/na-10585/.next/server/chunks/[turbopack]_runtime.js:636:12)
    at Object.<anonymous> (/Users/thangvu/repos/oss/na-10585/.next/server/app/auth/[...nextauth]/route.js:8:26)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at mod.require (/Users/thangvu/repos/oss/na-10585/node_modules/.pnpm/next@15.0.0-canary.75_react-dom@19.0.0-rc.0_react@19.0.0-rc.0__react@19.0.0-rc.0/node_modules/next/dist/server/require-hook.js:65:28)
    at require (node:internal/modules/helpers:130:18)
    at requirePage (/Users/thangvu/repos/oss/na-10585/node_modules/.pnpm/next@15.0.0-canary.75_react-dom@19.0.0-rc.0_react@19.0.0-rc.0__react@19.0.0-rc.0/node_modules/next/dist/server/require.js:109:84)
    at loadComponentsImpl (/Users/thangvu/repos/oss/na-10585/node_modules/.pnpm/next@15.0.0-canary.75_react-dom@19.0.0-rc.0_react@19.0.0-rc.0__react@19.0.0-rc.0/node_modules/next/dist/server/load-components.js:98:57) {
  code: 'MODULE_UNPARSEABLE',
  page: '/auth/signin'
}

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.3.0: Wed Dec 20 21:31:00 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6020
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 20.8.0
  npm: 10.1.0
  Yarn: 1.22.21
  pnpm: 9.0.6
Relevant Packages:
  next: 15.0.0-canary.75 // Latest available version is detected (15.0.0-canary.75).
  eslint-config-next: N/A
  react: 19.0.0-rc.0
  react-dom: 19.0.0-rc.0
  typescript: 5.4.4
Next.js Config:
  output: standalone

Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

I tested my reproduction against the latest canary

  next: 15.0.0-canary.75 // Latest available version is detected (15.0.0-canary.75).
  react: 19.0.0-rc.0
  react-dom: 19.0.0-rc.0

Removing --turbo flag will make it work again.

l0gicgate commented 1 month ago

We are experiencing the same issues. The error stack provides very little insight on what the root cause is. @leerob can we get some eyes on this please 🙏🏼 ? This is a show stopper for us in multiple projects. Not being able to use --turbo slows development down quite drastically.

akbarsaputrait commented 1 month ago

i'm facing the same issue with next@14.2.4, next-auth@^5.0.0-beta.20 and turbopack

LZL0 commented 1 month ago

Same here.

Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!

LZL0 commented 1 month ago

This issue was resolved in v14.3.0-canary.81.

balazsorban44 commented 1 month ago

Should be fixed in https://github.com/nextauthjs/next-auth/pull/11551

github-actions[bot] commented 2 weeks ago

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.