nuxt-auth: './core' is not defined by "exports" in next-auth/package.json

Environment

Nuxi 3.6.5 8:38:19 AM

RootDir: /Users/me/Development/vercel/drclinic-app
Nuxt project info: (copied to clipboard)



Reproduction

it is my first using @sidebase/nuxt-auth i start from scratch

npx nuxi@latest init my-app pnpm i -D @sidebase/nuxt-auth

then configure nuxt.config.ts

export default defineNuxtConfig({ modules: [ '@sidebase/nuxt-auth', ], auth: { globalAppMiddleware: true, },

next i install Prisma 5.1.1

then pnpm run dev

Describe the bug

Error while running project

[worker reload] [worker init] Package subpath './core' is not defined by "exports" in /Users/Me/Development/vercel/drclinic-app/node_modules/next-auth/package.json imported from /Users/Me/Development/vercel/drclinic-app/.nuxt/dev/index.mjs

Additional context

No response

Logs

✔ Nitro built in 162 ms                                                                                                                        nitro 8:31:16 AM

[8:31:16 AM]  ERROR  [worker reload] [worker init] Package subpath './core' is not defined by "exports" in /Users/Me/Development/vercel/drclinic-app/node_modules/next-auth/package.json imported from /Users/Me/Development/vercel/drclinic-app/.nuxt/dev/index.mjs

  at new NodeError (node:internal/errors:387:5)
  at throwExportsNotFound (node:internal/modules/esm/resolve:365:9)
  at packageExportsResolve (node:internal/modules/esm/resolve:649:3)
  at packageResolve (node:internal/modules/esm/resolve:833:14)
  at moduleResolve (node:internal/modules/esm/resolve:901:20)
  at defaultResolve (node:internal/modules/esm/resolve:1115:11)
  at nextResolve (node:internal/modules/esm/loader:163:28)
  at ESMLoader.resolve (node:internal/modules/esm/loader:841:30)
  at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
  at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)


🙏🏼please help me...  

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Reactions: 5
  • Comments: 17 (1 by maintainers)

Most upvoted comments

Easiest is to add

"overrides": {
    "next-auth": "4.22.5"
  },

to your package.json and to a clean install with npm install (you may need to delete package-lock.json and node_modules)

Once this issue is fixed, you can simply remove the override.

Not related to Prisma package, but next-auth

Due to https://github.com/nextauthjs/next-auth/commit/05ff6ae221b0434784e056de4bff6e3e45c49552 fix in https://github.com/nextauthjs/next-auth/releases/tag/next-auth%404.23.0

A solution is to downgrade to next-auth@4.22.5 Or, add manualy into package.json for the next-auth package :

"./core": {
      "types": "./core/index.d.ts",
      "default": "./core/index.js"
    },

I had the same problem and it was solved after the following installation ( example below via yarn )

yarn add next-auth@4.21.1 --legacy-peer-deps

Not related to Prisma package, but next-auth

Due to nextauthjs/next-auth@05ff6ae fix in https://github.com/nextauthjs/next-auth/releases/tag/next-auth%404.23.0

A solution is to downgrade to next-auth@4.22.5 Or, add manualy into package.json for the next-auth package :

"./core": {
      "types": "./core/index.d.ts",
      "default": "./core/index.js"
    },

Hey @agennari, thanks for this ! Patching next-auth with this did the trick. It seems we’re in a deadend here as the maintainer rejected a PR in that direction (https://github.com/nextauthjs/next-auth/pull/8496) @zoey-kaiser will you pin the peerDependency to the latest compatible next-auth i.e. v4.22.5, or what’s the plan?

Not related to Prisma package, but next-auth

Due to nextauthjs/next-auth@05ff6ae fix in https://github.com/nextauthjs/next-auth/releases/tag/next-auth%404.23.0

A solution is to downgrade to next-auth@4.22.5 Or, add manualy into package.json for the next-auth package :

"./core": {
      "types": "./core/index.d.ts",
      "default": "./core/index.js"
    },

hi all,

i already did it, it solved for development. it was running well.

then… i build run into docker container.

here is what i found


myApp_lite | Error [ERR_MODULE_NOT_FOUND]: 
Cannot find module '/app/.output/server/node_modules/next-auth/core/index.js' 
imported from /app/.output/server/index.mjs

Me either, nuxt 3.7.1 nuxt-auth 0.5.0 next-auth 4.21.1 works well.

Same for me with 0.5.0 on 3.7.0 release of nuxt. Thanks @andreasvirkus, works well for me !

Just upgraded to "nuxt": "^3.7.0" and I started getting the same error. I’m using "@sidebase/nuxt-auth": "^0.6.0-beta.4",. Doing what @dschreij suggested worked for me