prisma: Qwikcity: Error during build for Vercel Edge
Bug description
".prisma/client/index-browser" is imported by ".prisma/client/index-browser?commonjs-external", but could not be resolved – treating it as an external dependency.
error during build:
TypeError [PLUGIN_ERROR]: Invalid module ".prisma/client/index-browser" is not a valid package name imported from /Users/harshmangalam/qwik-prisma/.vercel/output/functions/_qwik-city.func/assets/@qwik-city-plan-2c65295d.js
at new NodeError (node:internal/errors:399:5)
at parsePackageName (node:internal/modules/esm/resolve:817:11)
at packageResolve (node:internal/modules/esm/resolve:840:5)
at moduleResolve (node:internal/modules/esm/resolve:938:20)
at defaultResolve (node:internal/modules/esm/resolve:1153:11)
at nextResolve (node:internal/modules/esm/loader:163:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
at link (node:internal/modules/esm/module_job:76:36)
How to reproduce
- pnpm qwik add vercel-edge
- pnpm run build
Expected behavior
No response
Prisma information
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
}
import { PrismaClient } from "@prisma/client";
export const prisma = new PrismaClient();
Environment & setup
- OS: macOS
- Database: PostgreSQL
- Node.js version: v18.16.0
Prisma Version
5.3.1
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 2
- Comments: 15 (10 by maintainers)
I ran into this issue when working with CloudFlare pages.
Invalid module ".prisma/client/edge" is not a valid package nameimport { PrismaClient } from '@prisma/client/edge';I found this link that helped me fix it: https://fixtergeek.com/blog/how-to-use-prismaclient-with-qwik-on-cloudflare-pages-2023
vite.config.ts
If you’re using PNPM, the Prisma Client may not be in node_modules/.prisma, but you can change the output directory in schema.prisma.
I can confirm this:
Two problems:
@prisma/clientcurrently does not work on Edge Functions, including Vercel Edge Functions or Runtime. Reproduction see: https://github.com/janpio/prisma-qwik@prisma/client/edgedoes not work out of the box: Reproduction see https://github.com/janpio/prisma-qwik/tree/data-proxy@harshmangalam You original problem is expected right now, as Prisma does not support Vercel Edge Functions out of the box which Qwik’s
vercel-edgeuses. You can follow this issue here for updates on this: https://github.com/prisma/prisma/issues/20566The second problem is unexpected and something we might want to investigate independently - I will keep this issue for that.
@harshmangalam for
pnpmyou will need to try something like this:@Jolg42 It works for me when using
npmbut got following errors withpnpm.I found out that this could be solved with 2 aliases, see my repro here: https://github.com/Jolg42/prisma-repro-21094
This is what worked for me: https://github.com/Jolg42/prisma-repro-21094/blob/main/adapters/vercel-edge/vite.config.ts
I found out about this in Vite’s docs here https://vitejs.dev/guide/features#webassembly
@harshmangalam @blakeley @eglove Could you try that and let us know if that works for you too?
Note: I found the related issues in qwik’s repo:
I had the same issue above (and resolved it with the same resolution above). I just attempted to upgrade to 5.11.0 and I’m now getting a similar issue:
I tried a similar fix, but it did not resolve the issue:
Instead, I get the following error: