Search code examples
svelteprismavercelsappersvelte-3

Zeit : Prisma 2 did not initialize yet error


I'm using prisma 2 client with zeit for developing a sapper app. Everything works fine in my local but when tried to deploy on zeit, majority of the times it will fail and magically it works sometimes. Not really sure if there should be some configuration changes that I have to do.

Error: @prisma/client did not initialize yet. Please run "prisma2 generate" and try to import it again.

I saw some similar problem with zeit here but that did not work in my case. https://github.com/prisma/prisma-client-js/issues/390

Need help please.


Solution

  • This is likely due to the way that Zeit caches the node_modules.

    Prisma generates the client in the @prisma/client module found in node_modules and if it isn't generated it throws the error that you see.

    Two solutions:

    • Upgrade Prisma to 2.0.0-preview021 which has a fix for this
    • Add a postinstall script in your package.json with prisma2 generate

    The latter isn't strictly necessary if you're using the latest version.