Anyone here figured out how to make Prisma library...
# orm-help
s
Anyone here figured out how to make Prisma library available as a lambda layer when deploying to Serverless locally?
āœ… 1
o
As in serverless offline?
s
No to AWS Lambda
Locally it works fine
The problem is I am generating the Prisma Client locally and then running
Copy code
sls deploy
This is giving me a weird error:
Copy code
"Runtime.UnhandledPromiseRejection: Error: Query engine library for current platform \"rhel-openssl-1.0.x\" could not be found.",
        "You incorrectly pinned it to rhel-openssl-1.0.x",
        "",
        "This probably happens, because you built Prisma Client on a different platform.",
        "(Prisma Client looked in \"/var/task/src/libquery_engine-rhel-openssl-1.0.x.so.node\")",
        "",
        "Searched Locations:",
        "",
        "  /.prisma/client",
        "  /Users/<username>/<path-to-project>/node_modules/@prisma/client",
        "  /var/task",
        "  /var/task/src",
        "  /var/task/src",
        "  /tmp/prisma-engines",
        "  /var/task/src",
        "",
        "You already added the platforms \"darwin\", \"rhel-openssl-1.0.x\" to the \"generator\" block",
        "in the \"schema.prisma\" file as described in <https://pris.ly/d/client-generator>,",
        "but something went wrong. That's suboptimal.",
        "",
        "Please create an issue at <https://github.com/prisma/prisma/issues/new>",
        "    at process.<anonymous> (file:///var/runtime/index.mjs:1131:17)",
        "    at process.emit (node:events:527:28)",
        "    at emit (node:internal/process/promises:140:20)",
        "    at processPromiseRejections (node:internal/process/promises:274:27)",
        "    at processTicksAndRejections (node:internal/process/task_queues:97:32)"
Though I have added this in my generator block:
Copy code
binaryTargets   = ["native", "rhel-openssl-1.0.x"]
And I also have this environment variable set:
Copy code
PRISMA_QUERY_ENGINE_LIBRARY: /opt/prisma-binary
But it is not searching this path when running the server as you can see from the error logs.
When I do:
Copy code
ls /opt/prisma-binary
I get:
Copy code
libquery_engine-rhel-openssl-1.0.x.so.node
Got this working with this changing the
PRISMA_QUERY_ENGINE_LIBRARY
path from:
Copy code
/opt/prisma-binary
to the actual library file like so:
Copy code
/opt/prisma-binary/libquery_engine-linux-arm64-openssl-1.0.x.so.node
k
You need to package the engine and schema i believe...
Copy code
package: {
        individually: true,
        patterns: [
            ".prisma-layer/nodejs/node_modules/.prisma/client/schema.prisma",
            ".prisma-layer/nodejs/node_modules/.prisma/client/libquery_engine-${env:PRISMA_BINARY_TARGET}-*",
        ],
    },
Im also curious if you are using the serverless typescript template?
v
šŸ‘‹ Hello @Samrith Shankar, I hope you're keeping well! Did you end up resolving this issue or it is still an open question?
s
@Kay Khan just giving the path solved it. I’m using NestJS for this
@Vladi Stevanovic yes this is twice as per this issue: https://github.com/prisma/prisma/issues/15029
šŸ’Æ 1