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

fix(errors): expose custom errors #1816

Merged
merged 3 commits into from
Apr 22, 2021
Merged

fix(errors): expose custom errors #1816

merged 3 commits into from
Apr 22, 2021

Conversation

balazsorban44
Copy link
Member

@balazsorban44 balazsorban44 commented Apr 22, 2021

What:

Exposes all the custom errors (and adds new ones). under next-auth/errors

Why:

These errors can be very useful when creating adapters.

How:

Went through the currently available adapters and extracted the types of errors that I thought could be defined as custom errors instead.

Checklist:

  • Documentation
  • Tests
  • Ready to be merged

@vercel
Copy link

vercel bot commented Apr 22, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nextauthjs/next-auth/Fb9FjXEVGjJ2q2WjQGEG9oUn8Wk3
✅ Preview: https://next-auth-git-fix-export-errors-nextauthjs.vercel.app

@github-actions github-actions bot added the core Refers to `@auth/core` label Apr 22, 2021
@balazsorban44 balazsorban44 merged commit be28672 into main Apr 22, 2021
@balazsorban44 balazsorban44 deleted the fix/export-errors branch April 22, 2021 21:28
@github-actions
Copy link

🎉 This PR is included in version 3.15.12 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version 4.0.0-next.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@shnupta
Copy link

shnupta commented May 31, 2021

Hi, I'm getting the following error when trying to import Prisma adapter and client into my [...nextauth].js file. This happens at runtime when I load any page.

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './dist/lib/errors' is not defined by "exports" in /Users/casey/dev/donarity/node_modules/next-auth/package.json
    at new NodeError (node:internal/errors:363:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:321:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:546:3)
    at resolveExports (node:internal/modules/cjs/loader:478:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:518:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:927:27)
    at Function.mod._resolveFilename (/Users/casey/dev/donarity/node_modules/next/dist/build/webpack/require-hook.js:4:1855)
    at Function.Module._load (node:internal/modules/cjs/loader:774:27)
    at Module.require (node:internal/modules/cjs/loader:1013:19)
    at require (node:internal/modules/cjs/helpers:93:18)
    at Object.<anonymous> (/Users/casey/dev/donarity/node_modules/@next-auth/prisma-adapter/dist/index.js:54:16)
    at Module._compile (node:internal/modules/cjs/loader:1109:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
    at Module.load (node:internal/modules/cjs/loader:989:32)
    at Function.Module._load (node:internal/modules/cjs/loader:829:14)
    at Module.require (node:internal/modules/cjs/loader:1013:19) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

My package.json looks like this:

{
  "name": "donarity",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start"
  },
  "dependencies": {
    "@next-auth/prisma-adapter": "^0.4.4",
    "@prisma/client": "^2.23.0",
    "bootstrap": "^4.6.0",
    "next": "10.2.3",
    "next-auth": "^3.23.3",
    "pg": "^8.6.0",
    "react": "17.0.2",
    "react-bootstrap": "^1.6.0",
    "react-dom": "17.0.2",
    "sass": "^1.34.0"
  },
  "devDependencies": {
    "prisma": "^2.23.0"
  }
}

I've checked in node_modules/ and ./dist/lib/errors.js is definitely being exported.

This seems to only happen if I try to use import { PrismaAdapter } from "@next-auth/prisma-adapter" whereas if I use the import Adapters from "next-auth/adapters" method I don't get this error. I was following the guidance on the next auth adapter page.

@balazsorban44
Copy link
Member Author

please have a look at the closed issues at https://github.com/nextauthjs/adapters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Refers to `@auth/core`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants