adminjs-prisma icon indicating copy to clipboard operation
adminjs-prisma copied to clipboard

Cannot find module '@adminjs/prisma' or its corresponding type declarations.ts(2307)

Open musadgn opened this issue 1 year ago • 13 comments

"@adminjs/prisma": "^4.0.0",

when I installed v4.0.0 it can't find only '@adminjs/prisma' when '@adminjs/sql' and '@adminjs/express' works well.
I removed node_modules and package-lock.json and reinstalled but still same error.

musadgn avatar Jun 01 '23 11:06 musadgn

Hello! You might want to modify tsconfig.json, changing property moduleResolution value to Node16. I've had Node and I had the same issue.

mkramek avatar Jul 05 '23 13:07 mkramek

same issue. changing moduleResolution didn't work. image

luisrudge avatar Jul 20 '23 21:07 luisrudge

Same issue here

MoSattler avatar Jul 24 '23 14:07 MoSattler

I have the same problems and I tried using different versions of @adminjs/prisma.

felipesotero avatar Jul 27 '23 20:07 felipesotero

Did you try importing without * as AdminJSPrisma? This could be wrapping the entire module into another namespace hence TS complaints.

Try to do the imports similar to example app: https://github.com/SoftwareBrothers/adminjs-prisma/blob/main/example-app/src/index.ts

dziraf avatar Jul 28 '23 07:07 dziraf

Yes, @dziraf. Same problem. image

Not sure if important, but I'm using Ubuntu 22 with WSL2, Windows 11.

felipesotero avatar Jul 28 '23 12:07 felipesotero

can you share package.json and tsconfig.json?

dziraf avatar Jul 28 '23 12:07 dziraf

I was actually trying to append AdminJS in an existing project, but after seeing the same problem, I created a new project from scratch with just the default package.json and following the basic Getting Started section on AdminJS's website. So this is the current package.json:

{
  "name": "adminjs-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@adminjs/express": "^6.0.0",
    "@adminjs/prisma": "^5.0.1",
    "adminjs": "^7.2.0",
    "express": "^4.18.2",
    "express-formidable": "^1.2.0"
  }
}

felipesotero avatar Jul 28 '23 13:07 felipesotero

Yeah, seems to be a general problem for me, too. In different projects.

MoSattler avatar Jul 31 '23 09:07 MoSattler

Looks like you might need:

"type": "module"

in your package.json since AdminJS is ESM-only now. Some tsconfig.json modifications might be needed as well but from my experience setting module and moduleResolution to nodenext is enough. Alternatively, you can try to set up the example app from this repo and look for differences in setup since it works for me.

dziraf avatar Jul 31 '23 12:07 dziraf

Thanks for the advice! Unfortunately, I can't add those changes to my project. For now, I'm using ts-ignore comments to suppress the AdminJS errors. If problems persist, I might roll back AdminJS or consider alternatives as a last resort. Thank you for your help!

MoSattler avatar Aug 02 '23 09:08 MoSattler

This fixed the issue, thanks!

mirashif avatar Aug 17 '23 05:08 mirashif

Hello, still got the same issue here, Got "type": "module" "@adminjs/prisma": "^5.0.3" in my package.json and"moduleResolution": "bundler" in my tsconfig.json

AlexandreBrayer avatar Mar 25 '24 11:03 AlexandreBrayer

same issue tried different tsconfig.json configurations but same issue persists.

kavyantic avatar May 07 '24 14:05 kavyantic