Missing schema.prisma in lambda layer
See original GitHub issueI’m testing prisma 3.0.2 and 3.1.1 with NPM v7 workspaces -
It’s not running properly in my lambda function/layer setup. I get the error ENOENT: no such file or directory, open '/var/task/schema.prisma'
Can I at least tell it what path my schema.prisma file is at somehow? I couldn’t find anything in the docs. I have the file in a lambda layer (/opt/nodejs/prisma)
 
Additionally, it seems like in Prisma 3 it now is trying to find the schema.prisma file when I import the file that constructs my prisma client (new PrismaClient()), whereas before it didn’t do that. This is a problem for me because some of my lambda functions are set up to use prisma (with secrets, layer, network access to the DB, etc) and some aren’t but still import files which import the prisma client. So now I can’t start the functions that don’t have anything to do with prisma because it explodes saying it can’t find schema.prisma even though I have no intention of using it in that function.
    "stack": [
        "Error: ENOENT: no such file or directory, open '/var/task/schema.prisma'",
        "    at Object.openSync (fs.js:498:3)",
        "    at Object.readFileSync (fs.js:394:35)",
        "    at new LibraryEngine (/var/task/index.js:139195:46)",
        "    at PrismaClient.getEngine (/var/task/index.js:151600:20)",
        "    at new PrismaClient (/var/task/index.js:151569:33)",
        "    at packages/repo/build/client.js (/var/task/index.js:156432:18)",
        "    at __require (/var/task/index.js:38:45)",
        "    at packages/repo/build/index.js (/var/task/index.js:187999:20)",
        "    at __require (/var/task/index.js:38:45)",
        "    at packages/domain/build/auth/user/invite.js (/var/task/index.js:233728:27)"
    ]
Ideally the engine would lazily load the library engine when I actually need it and I could tell it where to find the schema prisma file.
Even better would be if it searched up from the node_modules dir (which lives in the layer) until it found a prisma dir and then looked in there for the schema file.
_Originally posted by @revmischa in https://github.com/prisma/prisma/issues/9435#issuecomment-930308899_
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:20 (2 by maintainers)

 Top Related Medium Post
Top Related Medium Post Top Related StackOverflow Question
Top Related StackOverflow Question
@natevaughan @field123 I also was facing this issue and copying over the
postbuildscript from this example solved the issue for me: https://github.com/mikenikles/sveltekit-prisma/blob/main/package.jsonI’m running into this when using SvelteKit on Vercel and hitting a serverless function in SvelteKit’s
apidirectory:Everything works locally. Happy to provide more details or an example repo if helpful.