next-auth icon indicating copy to clipboard operation
next-auth copied to clipboard

Cannot find module '@auth/prisma-adapter' from 'my.test.ts'

Open totobest opened this issue 10 months ago • 0 comments

Adapter type

@auth/prisma-adapter

Environment

System: OS: Linux 6.5 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish) CPU: (16) x64 12th Gen Intel(R) Core(TM) i7-1270P Memory: 21.23 GB / 30.58 GB Container: Yes Shell: 5.1.16 - /bin/bash Binaries: Node: 20.12.0 - ~/.nvm/versions/node/v20.12.0/bin/node Yarn: 1.22.19 - /usr/bin/yarn npm: 10.5.0 - ~/.nvm/versions/node/v20.12.0/bin/npm Browsers: Chrome: 122.0.6261.111 npmPackages: @auth/prisma-adapter: ^2.0.0 => 2.0.0 next-auth: ^4.24.7 => 4.24.7

Reproduction URL

https://github.com/totobest/next-auth-ts-jest

Describe the issue

tsconfig.json

{
  "extends": "@tsconfig/recommended/tsconfig.json"
}

my.test.js

import { PrismaAdapter } from "@auth/prisma-adapter"
import NextAuth from "next-auth"

PrismaAdapter

test("it works", () ={
    expect(3).toBe(3)
})

package.json

{
  "name": "next-auth-ts-jest",
  "version": "1.0.0",
  "dependencies": {
    "@auth/prisma-adapter": "^2.0.0",
    "@prisma/client": "^5.12.1",
    "next-auth": "^4.24.7"
  },
  "devDependencies": {
    "@tsconfig/recommended": "^1.0.6",
    "@types/jest": "^29.5.12",
    "jest": "^29.7.0",
    "prisma": "^5.12.1",
    "ts-jest": "^29.1.2",
    "typescript": "^5.4.5"
  }
}

How to reproduce

$ yarn jest
yarn run v1.22.19
 FAIL  ./my.test.ts
  ● Test suite failed to run

    Cannot find module '@auth/prisma-adapter' from 'my.test.ts'

      1 |
    > 2 | import { PrismaAdapter } from "@auth/prisma-adapter"
        | ^
      3 | import NextAuth from "next-auth"
      4 |
      5 |

      at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:427:11)
      at Object.<anonymous> (my.test.ts:2:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.972 s
Ran all test suites.

Expected behavior

No error

totobest avatar Apr 20 '24 08:04 totobest