prisma: Query engine binary could not be found on netlify deployment with Next

Bug description

Query engine binary for current platform "rhel-openssl-1.0.x" could not be found. This probably happens, because you built Prisma Client on a different platform. (Prisma Client looked in "/query-engine-rhel-openssl-1.0.x") Searched Locations: /.prisma/client /opt/build/repo/node_modules/@prisma/client / /var/task/node_modules/.prisma/client /var/task /var/task/node_modules/.prisma/client You already added the platforms "native", "rhel-openssl-1.0.x", "darwin" 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-client-js/issues/new

Note: checked the following: https://github.com/netlify/zip-it-and-ship-it/issues/81
https://github.com/prisma/prisma/issues/1015 https://github.com/netlify/build/issues/730#issuecomment-615177926

How to reproduce

Deploy a simply nextjs + prisma app to netlify

Expected behavior

Prisma client should do CRUD as usually.

Prisma information

generator client {
  provider = "prisma-client-js"
  binaryTargets = ["native", "rhel-openssl-1.0.x", "darwin"]
  previewFeatures = ["createMany"]
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

Environment & setup

  • OS: Netlify
  • Database: Postgres
  • Node.js version: 12.18.0
  • Prisma version: 2.18.0

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 30 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Netlify’s bundling tool zip-it-and-ship-it includes your dependency files into the zip file by looking at your imports. Since next rewrites all imports with webpack, zip-it-and-ship-it will not see the import and files such as binaries won’t be bundled. Netlify is working on a general solution for these kind of issues, but without any concrete date yet. I propose this workaround, where we simply exclude @prisma/client from being bundled:

next.config.js

module.exports = {
    webpack: (config, { isServer } ) => {
        if (isServer) {
            config.externals.push('@prisma/client')
        }

        return config
    },
    target: "serverless"
}

Confirmed TypeError: debugLib is not a function is no longer happening. Thanks for the fix!

Thanks everyone, in the latest dev version, we fixed the debugLib is not a function problem. It’ll get released in 2.20.0 today.

The original error reported in this issue binary for current platform "rhel-openssl-1.0.x" could not be found is not fixed by this though. We will continue investigating that next sprint.

It is reproducible, we will patch it or document a workaround. Stay tuned.

I’m not using netlify and am getting this issue after upgrade from 2.17.? to 2.20.1:

@timsuchanek Was this definitely fixed in 2.20 ?

14:06:03 - Found 0 errors. Watching for file changes.
C:\SourceCode\proj\node_modules\.prisma\client\index.js:21
const debug = debugLib('prisma-client')
              ^

TypeError: debugLib is not a function
    at Object.<anonymous> (C:\SourceCode\proj\node_modules\.prisma\client\index.js:21:15)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (C:\SourceCode\proj\node_modules\@prisma\client\index.js:1:16)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)

We have an idea what might be going on and are investigating.

Also having this issue with a next.js app deployed to netlify: https://github.com/jhackett1/example-deploy-to-netlify-app

Are we any closer to a resolution or workaround?

Deploying the same app to Vercel works fine: https://example-deploy-to-netlify-app.vercel.app/

@webnoob since this issue is about Query engine binary could not be found on netlify deployment I will mark the debugLib is not a function messages off topic to keep the issue clean.

Glad you’re unblocked!

i seem to still be getting the original issue on version 2.20.1 😦

https://next-auth.js.org/errors#get_user_by_provider_account_id_error PrismaClientInitializationError2 [PrismaClientInitializationError]: Query engine binary for current platform "rhel-openssl-1.0.x" could not be found.
This probably happens, because you built Prisma Client on a different platform.
(Prisma Client looked in "/query-engine-rhel-openssl-1.0.x")

Searched Locations:

  /.prisma/client
  /opt/build/repo/node_modules/@prisma/client
  /
  /var/task/node_modules/.prisma/client
  /var/task
  /var/task/node_modules/.prisma/client

You already added the platforms "native", "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 cb (/var/task/src/nextPage/index.js:116764:17) {
  clientVersion: '2.20.1',
  errorCode: undefined
}

you can see the repo i’m trying to deploy here: https://github.com/jhackett1/sms-message-tool

i was getting the “debuglib” issue before, so this is progress of a sort, i suppose!

I’ve had TypeError: debugLib is not a function happening locally. Next.js (latest version), macOS. Downgrading Prisma to 2.18.0 fixed it.

repo: https://github.com/s-kris/test-prisma-netlify

hey @pantharshit00 looks like Query engine binary is with 2.18.0 Link: https://cocky-babbage-06fac3.netlify.app/api/prisma-test branch: master

I’m able to reproduce the TypeError: debugLib is not a function with 2.19.0 Link: https://60533b09c4bfae0007861e2c--cocky-babbage-06fac3.netlify.app/api/prisma-test branch: p2.19

Thanks for your time 😃

 Build error occurred
TypeError: debugLib is not a function

this error is happening on localhost Windows 10 too.

repo: https://github.com/s-kris/test-prisma-netlify

hey @pantharshit00 looks like Query engine binary is with 2.18.0 Link: https://cocky-babbage-06fac3.netlify.app/api/prisma-test branch: master

I’m able to reproduce the TypeError: debugLib is not a function with 2.19.0 Link: https://60533b09c4bfae0007861e2c--cocky-babbage-06fac3.netlify.app/api/prisma-test branch: p2.19

Thanks for your time 😃

Minimal repo https://github.com/s-kris/test-prisma-netlify You need to visit /api/prisma-test to see the error response.