DriverPackageNotInstalledError

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

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) 

package.json

{
  "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"
  }
}

Thanks for the report, @Riglanto! Are you using next-on-netlify or no? Sorry I am not a next.js expert (yet) so not sure if this is related to that or not. If you are using next-on-netlify, mind filing a bug here?

If not, please let me know and we’ll see what we can come up with with some help from the more next-savvy of our colleagues :slight_smile:

Thanks @fool .

As you can see on package.json I’m using next-on-netlify

Posted the issue on their github - [next-auth][error][adapter_connection_error] DriverPackageNotInstalledError · Issue #154 · netlify/next-runtime · GitHub

1 Like