Closed ankur198 closed 1 month ago
Hi @ankur198 👋
Why do you belive this is an issue with @sidebase/nuxt-auth
? Have you checked with the team behind @prisma/nuxt
where this error may be coming from?
As a quick workaround for this issue, you could install Prisma without the Nuxt module as we also recommend in create-sidebase
(npm create sidebase@latest
):
pnpm i -D prisma
pnpm i @prisma/client
// file: ~/server/middleware/0.prisma.ts
import { PrismaClient } from '@prisma/client'
let prisma: PrismaClient
declare module 'h3' {
interface H3EventContext {
prisma: PrismaClient
}
}
export default eventHandler((event) => {
if (!prisma) {
prisma = new PrismaClient()
}
event.context.prisma = prisma
})
// file: ~/prisma/utils.ts
import { execSync } from 'node:child_process'
/**
* Helper to reset the database via a programmatic prisma invocation. Helpful to add to \`beforeEach\` or \`beforeAll\` of your testing setup.
*
* WARNING: Never run this in production.
*
* Taken from https://github.com/prisma/prisma/issues/13549#issuecomment-1144883246
*
* @param databaseUrl Connection URL to database. Inferred from \`process.env.DATABASE_URL\` if not provided
*/
export function resetDatabase(databaseUrl?: string) {
const url = databaseUrl || process.env.DATABASE_URL
if (!url) {
throw new Error('Cannot reset database - connection string could not be inferred.')
}
if (process.env.NODE_ENV === 'production') {
throw new Error('This utility should not be called in production. It is meant for testing and development')
}
execSync(\`cd \${process.cwd()} && DATABASE_URL=\${url} npx prisma db push --force-reset\`, { stdio: 'inherit' })
}
Hi @zoey-kaiser ,
Thanks for responding and yes you are correct. I have seen @prisma/nuxt is not compatible with a lot of other libraries. My bad. Closing the issue.
Thanks for providing workaround though 🙂
Environment
Nuxt project info: 7:51:21 AM
Build Modules: -
Reproduction
npx nuxi@latest init test-nuxt-app
now
npm run dev
failsDescribe the bug
RollupError: node_modules/@prisma/nuxt/dist/runtime/server/utils/prisma.d.ts (2:8): Expected ';', '}' or (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;
Additional context
No response
Logs
No response