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

Prisma unusable #35

Closed
Ed1ks opened this issue Aug 28, 2024 · 8 comments
Closed

Prisma unusable #35

Ed1ks opened this issue Aug 28, 2024 · 8 comments
Assignees
Labels
bug Something isn't working nuxt-module priority/P0

Comments

@Ed1ks
Copy link

Ed1ks commented Aug 28, 2024

Hello,
i cant find a way to get prisma working with nuxt.
There is always bunch of errors - even in minimalistic setup.
I tried bun, yarn, pnpm - nothing works. Not in Stackblitz and not local.
It hungs up detecting PrismaClient, makes npx ENONENT or something else

image

or other errors.
I anyone getting it somehow working?

https://stackblitz.com/edit/nuxt-starter-zgouyq

@Ed1ks
Copy link
Author

Ed1ks commented Aug 28, 2024

I`ve fixed this by not using @prisma/nuxt.
Just copied the nice code for the singleton of prismaConnection into ~~/prisma/index.ts:

import { PrismaClient, Prisma } from '@prisma/client'

const prismaClientSingleton = () => {
  return new PrismaClient()
}

declare const globalThis: {
  prismaGlobal: ReturnType<typeof prismaClientSingleton>;
} & typeof global;

const prisma = globalThis.prismaGlobal ?? prismaClientSingleton()

export default prisma

if (process.env.NODE_ENV !== 'production') globalThis.prismaGlobal = prisma

and import import prisma from "~~/prisma" it to use prisma.

added this shamefully-hoist=true into the .npmrc file for pnpm.

Now everything works like a sharm.
@prisma/nuxt is indeed not production ready

@muneebbug
Copy link

In my case, I solved it temporarily like this.

When you see this prompt in the console,
"Do you want to view and edit your data by installing Prisma Studio in Nuxt DevTools? » (Y/n)"

press 'N', it will skip installing the Prisma studio and the error should go.

image

alternatively, you can add the following to nuxt.config.ts

export default defineNuxtConfig({
  prisma: {
    installStudio: false,
  }
})

and it will skip the step.

I checked the code and the error seems to come from this installStudio() function in the /src/package-utils/setup-helpers.ts file.

export async function installStudio(directory: string) {
  try {
    const { spawn } = require("child_process");

    log(PREDEFINED_LOG_MESSAGES.installStudio.action);

    await spawn("npx", ["prisma", "studio", "--browser", "none"], {
      cwd: directory,
    });

    logSuccess(PREDEFINED_LOG_MESSAGES.installStudio.success);

    return true;
  } catch (err) {
    logError(PREDEFINED_LOG_MESSAGES.installStudio.error);
    log(err);
    return false;
  }
}

@Kuuzoo
Copy link
Contributor

Kuuzoo commented Nov 25, 2024

Is there any update on this?
Also what about using other runtimes like bun? If I'm not mistaken I guess there was already usage of bun x, pnpm exec, etc but it seems to have been removed?

@ankur-arch can you maybe comment on why this (8820362) did get removed?

Thanks in advance

@ankur-arch
Copy link
Contributor

Hey there @Kuuzoo 👋,

Also, what about using other runtimes like bun? If I'm not mistaken I guess there was already usage of bun x, pnpm exec, etc., but it seems to have been removed?

You’re absolutely right—those were included previously. However, module installation was encountering consistent failures, so I had to remove them temporarily. I’m actively working on resolving these issues and plan to revisit this in the coming weeks. Your patience is greatly appreciated as I work through it!

Can you maybe comment on why this (https://github.com/prisma/nuxt-> prisma/commit/8820362a90838e3d431f94eb13bae77cbb5f0357) got removed?

Good question! From what I recall, local publishes were failing until that change was made.

@Kuuzoo
Copy link
Contributor

Kuuzoo commented Dec 24, 2024

Hey there @Kuuzoo 👋,

Also, what about using other runtimes like bun? If I'm not mistaken I guess there was already usage of bun x, pnpm exec, etc., but it seems to have been removed?

You’re absolutely right—those were included previously. However, module installation was encountering consistent failures, so I had to remove them temporarily. I’m actively working on resolving these issues and plan to revisit this in the coming weeks. Your patience is greatly appreciated as I work through it!

Can you maybe comment on why this (https://github.com/prisma/nuxt-> prisma/commit/8820362a90838e3d431f94eb13bae77cbb5f0357) got removed?

Good question! From what I recall, local publishes were failing until that change was made.

Hi there @ankur-arch, first of all merry christmas and big thank you for maintaining this project!

I think using the nypm package from unjs, could save a lot of time on making the package work with other package managers.

Since it brings all the following functions and is actively getting maintained, I think this is a good option for installing packages, detecting the package manager and so on.
Maybe you can have a look at it, and give me some feedback on what you think? Would highly appreciate it

image

@ankur-arch
Copy link
Contributor

Merry Christmas, @Kuuzoo! 🎄 Thanks for sharing this—I'll check it out. I'm currently working on a PR to add custom logic for detecting separate package managers, but nypm might be a better fit.

Here’s the PR: #71

@ankur-arch
Copy link
Contributor

ankur-arch commented Dec 28, 2024

Hey @Ed1ks,

Could you check if you're still experiencing the issue with the latest version, v0.2.0? If so, could you provide a reproduction so I can test it on my end?

Thanks!

@jharrell
Copy link
Member

Hi all, I'm closing this as stale. We have a couple of other issues that will handle things like bun support, etc. @Ed1ks @muneebbug if you are still having this issue, could you please open a new issue and describe the error you're seeing? Thanks.

@jharrell jharrell closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working nuxt-module priority/P0
Projects
None yet
Development

No branches or pull requests

5 participants