I am building a serverless function using the serverless framework. However im having an issue with running it locally
Error: ENOENT: no such file or directory, open ''/.esbuild/.build/node_modules/.prisma/client/schema.prisma'
prisma/schema.prisma
generator client {
    provider      = "prisma-client-js"
    binaryTargets = ["native", "rhel-openssl-1.0.x"]
}
serverless.ts
package: {
    individually: true,
    patterns: [
        "!node_modules/.prisma/client/libquery_engine-*",
        "node_modules/.prisma/client/libquery_engine-rhel-*",
        "!node_modules/prisma/libquery_engine-*",
        "!node_modules/@prisma/engines/**",
    ],
},
steps:
npx prisma generate && npm install 
sls invoke local -f main
What am i doing wrong here?
note:
attempting to follow this example: https://github.com/prisma/prisma-examples/tree/latest/deployment-platforms/aws-lambda
i am using the serverless aws-nodejs-typescirpt template which uses serverless-esbuild and not serverless-webpack
you can solve this by setting the location of Prisma Client. It works for both local and lambda.
prisma/schema.prisma
generator client {
  provider = "prisma-client-js"
  output   = "../src/generated/client"
}
npx prisma generate
serverless.ts
 package: {
    individually: true,
    patterns: [
      "src/generated/client/schema.prisma",
      "!src/generated/client/libquery_engine-*",
      "src/generated/client/libquery_engine-rhel-*",
      "!node_modules/prisma/libquery_engine-*",
      "!node_modules/@prisma/engines/**",
    ],
  },
some function
import { PrismaClient } from "../generated/client";
folder structure
- src
  - functions
  - generated
- serverless.ts
- ...
                        Looks like you are attempting to import the prisma.schema file from your node_modules file, which is not where it normally goes. Where is your prisma.schema file located relative to the root of your project?
If it's not in ./prisma.schema, you will need to configure its location by using this option:
https://www.prisma.io/docs/concepts/components/prisma-schema#prisma-schema-file-location
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With