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

[next-auth][error][adapter_connection_error] DriverPackageNotInstalledError #154

Closed
Riglanto opened this issue Jan 2, 2021 · 7 comments
Closed
Labels
priority: high type: bug code to address defects in shipped code

Comments

@Riglanto
Copy link

Riglanto commented Jan 2, 2021

Describe the bug
Please include a repo to reproduce your issue if you can!

To Reproduce
Issue: incorrect or missing library. Build/deploy is successful. The issue occurs on calling the api function.

Technical reason: Next-auth peer dependency is typeorm in latest aka buggy version.

Workaround: Force typeorm version via “resolutions” setting in package.json.

Probably cause: Resolutions form package.json are ignored.

Result on netlify - see the error log below.

Result on local env, Vercel - works with resolutions hack.

9:38:36 AM: 2020-12-28T08:38:36.854Z	0ea89e82-cf68-4a93-9678-222cc57f7acc	ERROR	[next-auth][error][adapter_connection_error] DriverPackageNotInstalledError: MongoDB package has not been found installed. Try to install it: npm install mongodb --save
    at new DriverPackageNotInstalledError (/var/task/src/node_modules/typeorm/error/DriverPackageNotInstalledError.js:10:28)
    at MongoDriver.loadDependencies (/var/task/src/node_modules/typeorm/driver/mongodb/MongoDriver.js:325:19)
    at new MongoDriver (/var/task/src/node_modules/typeorm/driver/mongodb/MongoDriver.js:139:14)
    at DriverFactory.create (/var/task/src/node_modules/typeorm/driver/DriverFactory.js:48:24)
    at new Connection (/var/task/src/node_modules/typeorm/connection/Connection.js:56:59)
    at ConnectionManager.create (/var/task/src/node_modules/typeorm/connection/ConnectionManager.js:56:26)
    at /var/task/src/node_modules/typeorm/index.js:196:66
    at step (/var/task/src/node_modules/tslib/tslib.js:141:27)
    at Object.next (/var/task/src/node_modules/tslib/tslib.js:122:57)
    at /var/task/src/node_modules/tslib/tslib.js:115:75 
https://next-auth.js.org/errors#adapter_connection_error
9:38:36 AM: 2020-12-28T08:38:36.854Z	0ea89e82-cf68-4a93-9678-222cc57f7acc	ERROR	[next-auth][error][oauth_callback_handler_error] TypeError: Cannot destructure property 'manager' of 'connection' as it is null.
    at Object.<anonymous> (/var/task/src/node_modules/next-auth/dist/adapters/typeorm/index.js:102:9)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/var/task/src/node_modules/next-auth/dist/adapters/typeorm/index.js:28:103)
    at _next (/var/task/src/node_modules/next-auth/dist/adapters/typeorm/index.js:30:194)
    at processTicksAndRejections (internal/process/task_queues.js:97:5) 
{
  "name": "test-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "start": "next start",
    "build": "next build",
    "export": "next export",
    "postbuild": "next-on-netlify",
    "test": "jest"
  },
  "resolutions": {
    "typeorm": "0.2.24"
  },
  "dependencies": {
    "aws-sdk": "^2.809.0",
    "axios": "^0.21.0",
    "bcrypt": "^5.0.0",
    "bootstrap": "^4.5.3",
    "date-fns": "^2.11.1",
    "faunadb": "^4.0.0",
    "fs-extra": "^9.0.1",
    "gray-matter": "^4.0.2",
    "local-storage": "^2.0.0",
    "mongodb": "^3.6.3",
    "next-auth": "^3.1.0",
    "object-hash": "^2.0.3",
    "qrcode": "^1.4.4",
    "react": "16.13.1",
    "react-bootstrap": "^1.4.0",
    "react-dom": "16.13.1",
    "react-icons": "^3.11.0",
    "react-scroll": "^1.8.1",
    "react-textarea-autosize": "^8.3.0",
    "reflect-metadata": "^0.1.13",
    "remark": "^12.0.0",
    "remark-html": "^12.0.0",
    "uuid": "^8.3.2",
    "yup": "0.31.1"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/plugin-proposal-decorators": "^7.12.1",
    "@types/bcrypt": "^3.0.0",
    "@types/fs-extra": "^9.0.4",
    "@types/jest": "^26.0.18",
    "@types/next-auth": "^3.1.18",
    "@types/node": "^14.14.9",
    "@types/object-hash": "^1.3.4",
    "@types/qrcode": "^1.3.5",
    "@types/react": "^17.0.0",
    "@types/react-scroll": "^1.8.2",
    "@types/sass": "^1.16.0",
    "@types/uuid": "^8.3.0",
    "@types/yup": "^0.29.10",
    "babel-jest": "^26.6.3",
    "dotenv-expand": "^5.1.0",
    "identity-obj-proxy": "^3.0.0",
    "jest": "^26.6.3",
    "jest-css-modules-transform": "^4.1.0",
    "jest-dom": "^4.0.0",
    "netlify-plugin-cache-nextjs": "^1.5.2",
    "next": "9.5.5",
    "next-on-netlify": "^2.6.3",
    "sass": "^1.30.0",
    "ts-node": "^9.1.0",
    "typescript": "^4.1.2"
  }
}

Versions

  • Next: "9.5.3"
  • next-on-netlify: "^2.6.3"

Initially posted on: https://community.netlify.com/t/driverpackagenotinstallederror/29063

@lindsaylevine
Copy link
Contributor

@Riglanto

  1. are you using target: serverless in next.config.js?
  2. unfortunately for something like this we'll need a simple deployable repo that reproduces your issue

@lindsaylevine
Copy link
Contributor

hey @Riglanto! any update here? :)

@Riglanto
Copy link
Author

Sorry for the delay @lindsaylevine

  1. The target is experimental-serverless-trace
  2. You can find failing example here: https://github.com/Riglanto/bug-app
  • you will need to set vars: NEXTAUTH_URL,GOOGLE_ID,GOOGLE_SECRET,NEXTAUTH_URL
  • also add your /api/auth/callback/google to google console.
  • deploy to Netlify and try to click signin button followed by logging with google
  • check logs for /functions/next_api_auth_nextauth

@lindsaylevine lindsaylevine transferred this issue from netlify/next-on-netlify Mar 16, 2021
@lindsaylevine lindsaylevine added priority: high type: bug code to address defects in shipped code labels Mar 19, 2021
@lindsaylevine
Copy link
Contributor

@Riglanto hey there, apologies this hasn't been given attention in awhile :/. i think it's because realistically we haven't had the time to dig into a package-specific issue (like next-auth) that would require us to go out of our way to grab secrets and whatnot. did you end up just using the workaround?

@Riglanto
Copy link
Author

Riglanto commented Jun 2, 2021

@lindsaylevine yes, I moved to Vercel platform.

@Jonzy3000
Copy link

@Riglanto I came across the same issue and the fix was to explicitly require the mongodb package in [...nextauth].ts

// pages/api/auth/[...nextauth].ts
import NextAuth, { InitOptions } from "next-auth";
import Providers from "next-auth/providers";

// The magic fix
require("mongodb");

const options: InitOptions = {
  providers: [
    Providers.Google({
      clientId: process.env.GOOGLE_ID,
      clientSecret: process.env.GOOGLE_SECRET,
    }),
  ],
  database: process.env.MONGO_DB_URI,
};

export default (req, res) => NextAuth(req, res, options);

Hope this helps!

@TimMTech
Copy link

I spoke to customer server for netlify. Horrible and not willing to help or walk you through. I even payed for multiple domains here. This is the last time I am ever using Netlify for anything. Moving ALL of my domains to vercel. Netlify is a heap of garbage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

4 participants