Hey, folks :wave: I'm having issues deploying Pris...
# orm-help
a
Hey, folks šŸ‘‹ I'm having issues deploying Prisma to Vercel: my edge function bundles
@prisma/client
, which attempts to read the
config2.datamodelPath
at
LibraryEngine
. Sharing more details below šŸ‘‡
I have a monorepo managed by Turborepo. Here's the monorepo structure:
Copy code
apps/
	web/
	  app/
		routes/
		  graphql.ts (imports "server", creates a GraphQL server baseds on the exported schema.

packages/
	clients/ (pulls the db, generates client)
    prisma.ts // imports "@prisma/client"
  server/
	  index.ts // exports a GraphQL schema.
    // one of its data sources uses prisma from "clients"
My deployment worked fine until I've added Prisma to my
clients
and
server
respectively. Here's the exception that happens on runtime when I hit my
/
edge function on Vercel:
Copy code
2022-02-08T15:29:19.468Z	undefined	ERROR	Error: ENOENT: no such file or directory, open '/var/task/output/server/pages/api/schema.prisma'
	at Object.openSync (fs.js:497:3)    at Object.readFileSync (fs.js:393:35)
	at new LibraryEngine (/var/task/output/server/pages/api/index.js:191039:40)
	at PrismaClient.getEngine (/var/task/output/server/pages/api/index.js:195362:16)
	at new PrismaClient (/var/task/output/server/pages/api/index.js:195333:29)
	at Object.<anonymous> (/var/task/output/server/pages/api/index.js:196256:19)
	at Module._compile (internal/modules/cjs/loader.js:1085:14)    	at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
	at Module.load (internal/modules/cjs/loader.js:950:32)
	at Function.Module._load (internal/modules/cjs/loader.js:790:12) {
I've had a chat with the Vercel team, they've suggested I research how to deal with Prisma client correctly, as
fs
operations are not supported by edge functions in Vercel (see https://vercel.com/docs/concepts/functions/edge-functions#runtime).
I use a build step for my
api/index.js
route that serves the entire app in Remix. The built route includes the source of prisma/client, which contains this line:
Copy code
var LibraryEngine = /* @__PURE__ */ __name(class extends Engine {
  constructor(config2) {
    super();
    var _a2, _b2;
    this.datamodel = import_fs.default.readFileSync(config2.datamodelPath, "utf-8");
Reading that datamodel is what throws a runtime exception in my edge function (because it relies on a
fs
operation).
I'd be extremely thankful for support on this. 1. Should the bundled prisma/client attempt to read something from fs? 2. How do I structure and bundle my repositories so this issue doesn't happen?
I can hop on a quick call as I've been solving this for a week now. Really want Prisma to work with my setup ā¤ļø
Perhaps something that's unusual according to all the docs/issues I find: • My prisma client is generated in one repo (
clients
) and is used in another repo through a dependency (
web -> server
). I really don't want to generate prisma client in the
web
repo, as everything should be prepared in the
clients
.
This is
prisma@3.9.1
Here's also a related issue on GitHub: https://github.com/prisma/prisma/issues/9520
r
@Artem I’m running into a similar issue — did you resolve yours in the end?
a
I've used Prisma Data Proxy.
r
Thanks, @Artem I found my issues were related to something else.