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

Nuxt 0.1.0 issues with d.ts files #61

Closed
husayt opened this issue Nov 21, 2024 · 16 comments · Fixed by #68
Closed

Nuxt 0.1.0 issues with d.ts files #61

husayt opened this issue Nov 21, 2024 · 16 comments · Fixed by #68
Assignees
Labels
bug Something isn't working

Comments

@husayt
Copy link

husayt commented Nov 21, 2024

Getting this error after upgrading to 0.1.0

ERROR  RollupError: ../node_modules/@prisma/nuxt/dist/runtime/server/utils/prisma.d.ts (2:8): Expected ';', '}' or <eof> (Note that you need plugins to import files that are not JavaScript)


import { PrismaClient } from "@prisma/client";
declare const prismaClientSingleton: () => PrismaClient<import(".prisma/client").Prisma.PrismaClientOptions, never, i...
           ^
declare const prisma: PrismaClient<import(".prisma/client").Prisma.PrismaClientOptions, never, import("@prisma/client...
export type CustomPrismaClient = ReturnType<typeof prismaClientSingleton>;
@ankur-arch ankur-arch added the bug Something isn't working label Nov 21, 2024
@ankur-arch
Copy link
Contributor

Thanks for reporting @husayt! I'll look into it!

@ankur-arch ankur-arch self-assigned this Nov 21, 2024
@ankur-arch
Copy link
Contributor

Hi @husayt, I appreciate your patience and apologize for the long wait.

I’ve picked this up again and wanted to clarify: when exactly does this issue occur? Also, which package manager are you using?

@ul8
Copy link

ul8 commented Nov 27, 2024

@ankur-arch I can jump in here since I have the same issue. I scaffolded a nuxt project using the latest versions a few days ago, see below my deps (removed nuxt-prisma in the meantime but also used 0.1.0)

I'm using pnpm and this occurs when I run pnpm run dev

 "dependencies": {
    "@nuxt/eslint": "^0.7.1",
    "@nuxt/eslint-config": "^0.7.1",
    "@nuxtjs/i18n": "^9.1.0",
    "@nuxtjs/seo": "^2.0.0-rc.23",
    "@nuxtjs/tailwindcss": "^6.12.2",
    "@pinia/nuxt": "^0.7.0",
    "@vueuse/core": "^11.3.0",
    "@vueuse/nuxt": "^11.3.0",
    "i18n": "^0.15.1",
    "nuxt": "^3.14.1592",
    "vue": "latest",
    "vue-router": "latest"
  },

@husayt
Copy link
Author

husayt commented Nov 27, 2024

@ul8 this module doesn't work with pnpm ( PR #30 should fix it, bot for some reason being ignored). So I use npm. But only 0.0.35 works, and only dev. So I can't build a working solution with any version of this module.

I just tried npm run dev with 0.1.1 and get this

[12:56:23]  WARN  [plugin inject] ../node_modules/@prisma/nuxt/dist/runtime/server/utils/prisma.d.ts: rollup-plugin-inject: failed to parse C:/myproject/node_modules/@prisma/nuxt/dist/runtime/server/utils/prisma.d.ts. Consider restricting the plugin to particular files via options.include


[nitro 12:56:23]  ERROR  RollupError: ../node_modules/@prisma/nuxt/dist/runtime/server/utils/prisma.d.ts (2:8): Expected ';', '}' or <eof> (Note that you need plugins to import files that are not JavaScript)


1: import { PrismaClient } from "@prisma/client";
2: declare const prismaClientSingleton: () => PrismaClient<import(".prisma/client").Prisma.PrismaClientOptions, never, i...
           ^
3: declare const prisma: PrismaClient<import(".prisma/client").Prisma.PrismaClientOptions, never, import("@prisma/client...
4: export type CustomPrismaClient = ReturnType<typeof prismaClientSingleton>;

This might be related to windows, but again there is another pr #37 waiting for some reason.

@ankur-arch there are PRs from community still open on issues affecting a lot of us, perhaps they are the key to this and other problems as well. To be honest getting @prisma and @prisma/nuxt to build and deploy (locally, firebase, cloudflare) are so much pain I already moved most of my projects to drizzle and it just works there without any drama. These issues are not difficult to resolve, but they have been out there for so long, I lost my confidence in Prisma being the reliable solution moving forward.

@ankur-arch
Copy link
Contributor

Thanks so much for your input on this issue 🙏,

@husayt, I’ve addressed some of your feedback in this comment — I appreciate your patience as I continue working through this.

Thanks @ul8! I’ll review this later this week and share any updates or findings.

@MuhamadAdrian
Copy link

In my case, the error comes when using sidebase/nuxt-auth and prisma/nuxt in the modules. But if im commented out the sidebase/nuxt-auth plugin, there is no error.

@gsxdsm
Copy link

gsxdsm commented Dec 1, 2024

Same issue. Using Nuxt/ui also breaks now with prisma

@koalli
Copy link

koalli commented Dec 2, 2024

Same Issue. Both side/nuxt-auth and atinux/nuxt-auth-utils will cause this problem. Just add these modules to the project and npm run dev.

@MuhamadAdrian
Copy link

For me it was now fixed by simply installing the prisma and @prisma/client packages, and creating a prismaClient instance manually.

@ankur-arch
Copy link
Contributor

For me it was now fixed by simply installing the prisma and @prisma/client packages, and creating a prismaClient instance manually.

I couldn't reproduce the exact error, but this resolves the issue and allows the project to run. It seems npm is failing to properly install and set up Prisma, leading to a preview failure with this error. Following the advice in the documentation helped resolve it.

Same Issue. Both [side/nuxt-auth](https://github.com/sidebase/nuxt-auth) and [atinux/nuxt-auth-utils](https://github.com/atinux/nuxt-auth-utils) will cause this problem. Just add these modules to the project and npm run dev.

Thanks, @koalli! I'll try this out and see if I can reproduce the exact error. I'm a bit tied up until tomorrow but will aim to get to this by Friday. Thanks, everyone!

@gsxdsm
Copy link

gsxdsm commented Dec 4, 2024

Npm is installing and setting up prisma just fine. In fact you can prove this by deleting the .nuxt folder and doing a build. It will work perfectly. The first time. Build again and it fails. And the article you linked to with a fix doesn't work and is unrelated to this. There's a problem with how rollup is processing prisma and specifically the typescript portion. Something in prisma nuxt is not cooperating with rollup. I've been trying to debug the build step in Nuxt but haven't pinpointed it yet.

@ankur-arch
Copy link
Contributor

Thanks for the insight, @gsxdsm!

The article you linked to with a fix doesn't work and is unrelated to this.

I haven't been able to reproduce the exact error yet, as I haven’t tried @koalli's suggestion. In my case, I encountered the preview error linked here, which is why I mentioned it.

There's a problem with how rollup is processing Prisma, specifically the TypeScript portion. Something in Prisma Nuxt is not cooperating with Rollup. I've been trying to debug the Nuxt build step but haven't pinpointed it yet.

If you have any further insights or updates, I’d greatly appreciate it 🫶 !

@koalli
Copy link

koalli commented Dec 5, 2024

You can create a new Nuxt project and add the nuxt-prisma module, then add one of these auth modules. I can still reproduce the RollupError the day before yesterday.

@ankur-arch
Copy link
Contributor

Hey there @koalli, thanks so much for your suggestion and for your patience!

Could you please check if this issue is resolved in version 0.1.3? It appears to be working fine on my end. 😊

@koalli
Copy link

koalli commented Dec 17, 2024

@ankur-arch I tested version 0.1.3 and added the nuxi-auth-utils module to my previous project, everything seems fine now, and it no longer throws a RollupError when I run npm run dev or npm run build.

@ankur-arch
Copy link
Contributor

Thank you, @koalli for getting back to me and @husayt for reporting the issue.

This PR #68 resolves the problem and has been included in version 0.1.3.

@jharrell jharrell linked a pull request Dec 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants