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

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

Open
musadgn opened this issue Jun 1, 2023 · 19 comments

Comments

@musadgn
Copy link

musadgn commented Jun 1, 2023

"@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.
@mkramek
Copy link

mkramek commented Jul 5, 2023

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

@luisrudge
Copy link

same issue. changing moduleResolution didn't work.
image

@MoSattler
Copy link

Same issue here

@felipesotero
Copy link

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

@dziraf
Copy link
Collaborator

dziraf commented Jul 28, 2023

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

@felipesotero
Copy link

Yes, @dziraf. Same problem.
image

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

@dziraf
Copy link
Collaborator

dziraf commented Jul 28, 2023

can you share package.json and tsconfig.json?

@felipesotero
Copy link

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

@MoSattler
Copy link

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

@dziraf
Copy link
Collaborator

dziraf commented Jul 31, 2023

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.

@MoSattler
Copy link

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!

@mirashif
Copy link

This fixed the issue, thanks!

@AlexandreBrayer
Copy link

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

@kavyantic
Copy link

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

@nazarskrinskyi
Copy link

issue is still relevant(

@murtazabaanihali
Copy link

murtazabaanihali commented Jul 25, 2024

Hello, i fixed this issue.
Everything should be same as my pakage.json and tsconfig.json. (Files are attached)
package.json
tsconfig.json

Edit:
Use tsx instead of ts-node, like this
npm i -D tsx
npx tsx src/index.ts

instead of
npx ts-node src/index.ts

@murtazabaanihali
Copy link

Let me know if anyone needs help regarding this issue

@InshadS
Copy link

InshadS commented Sep 18, 2024

Hello, i fixed this issue. Everything should be same as my pakage.json and tsconfig.json. (Files are attached) package.json tsconfig.json

Edit: Use tsx instead of ts-node, like this npm i -D tsx npx tsx src/index.ts

instead of npx ts-node src/index.ts

While doing this, why is it needed to import a ts file with .js extension?

@OskarFdz11
Copy link

I have the same issue but with @adminjs/mongoose:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests