Skip to content

Document how to deploy Next.js on Netlify #1879

@matthewmueller

Description

@matthewmueller

Since netlify and next is a pretty common deployment pattern, it'd be nice for a solution to be google-able.

I'd love to see a callout on the netlify deployment guide or an FAQ item:

Symptom:

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

Problem:

Webpack in Next.js is removing import @prisma/client so zip-it-and-ship-it can't find that import. Because it can't find that import, it doesn't know how to link the binaries.

Solution

Adjust your next.config.js:

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

        return config
    },
    target: "serverless"
}
  • Marking it as external prevents webpack from mangling the @prisma/client import
  • zip-it-and-ship-it can then discover @prisma/client and add the binaries to the zip.

Context: prisma/prisma#6051 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    serverless-initiativeSee #orm-discovery-deployment-and-docstype/docsDocumentation creation, updates or corrections

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions