question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing schema.prisma in lambda layer

See original GitHub issue

I’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)

Screenshot 2021-09-29 at 18 53 50

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:open
  • Created 2 years ago
  • Reactions:6
  • Comments:20 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
ptyacommented, Dec 11, 2021

@natevaughan @field123 I also was facing this issue and copying over the postbuild script from this example solved the issue for me: https://github.com/mikenikles/sveltekit-prisma/blob/main/package.json

3reactions
natevaughancommented, Dec 6, 2021

I’m running into this when using SvelteKit on Vercel and hitting a serverless function in SvelteKit’s api directory:

Error: ENOENT: no such file or directory, open '/var/task/schema.prisma'
    at Object.openSync (fs.js:497:3)
    at Object.readFileSync (fs.js:393:35)
    at new LibraryEngine (/var/task/index.js:48098:44)
    at PrismaClient.getEngine (/var/task/index.js:51308:20)
    at new PrismaClient (/var/task/index.js:51279:33)
    at Object.<anonymous> (/var/task/index.js:53931:12)
    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)
 {  errno: -2,  syscall: 'open',  code: 'ENOENT',  path: '/var/task/schema.prisma',  clientVersion: '3.6.0'}

Everything works locally. Happy to provide more details or an example repo if helpful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deploying to AWS Lambda - Prisma
Prisma workflow · Define the database schema using SQL. · Run prisma db pull locally which will introspect and populate the schema.prisma with...
Read more >
Managing Lambda Size with Multiple Prisma Clients
Subscribe to my newsletter and never miss my upcoming articles ... We'll go ahead and rename that initial schema.prisma to dog.prisma ...
Read more >
Lets take Prisma 2 for a test drive on AWS Lambda ... - ITNEXT
With everything setup you should be able to write queries against your database. Since I am using GraphQL, I setup a simple schema:...
Read more >
Scan images with twistcli - Prisma Cloud
The file schema is being kept for backwards compatibility. ... The scan report won't show a layer-by-layer analysis of the image.
Read more >
Building a Serverless GraphQL API with Prisma, Apollo ...
We need to install the apollo-server-lambda & graphql packages in our… ... Next we will add the pothos generator to our prisma schema...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found