prisma: Error with Prisma v18.2: can't find schema.prisma

I updated Prisma version from 18.1 to 18.2, and then try to deploy Prisma to zeit/now and got an error.

$ prisma2 generate
$ Error: Can't find schema.prisma
$ error Command failed with exit code 1.

The most interesting thing is that this is not a call of prisma2 generate from my package.json, but a call somewhere from a Prisma. Does Prisma has its own postinstall hook for prisma2 generate? Because it is called immediately after the dependencies of another package are installed.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 17 (7 by maintainers)

Most upvoted comments

@pantharshit00 Finally. It’s how I’ve structured my app which is slightly different from other examples, hence I think it will help you test it against more cases. https://github.com/momakes/prisma0182-monorepo-bug PS. I can’t use prisma19 because of another issue, hence just used preview 18.2, but I reckon it’s the same with 019.

Ok, I can confirm this bug now. I was reproducing this and wasn’t able to remove the postinstall hook no matter what. Then I checked the code and sure enough we were mutating the package.json when NOW_BUILDER is set. So I talked internally on why we are doing this and explanantion is as following:

Now caches the node_modules folder. Then on every deploy they reexecute yarn install. If there was no change in the package.json, the posinstall hook of Photon doesn’t get reexecuted. Therefore, if we are in a Now environment, we add prisma2 generate to the postinstall hook of the users main package.json to fix this behavior. We also created an issue in yarn to track this: https://github.com/yarnpkg/yarn/issues/7762

We should just make this thing fail silently and fix this workspace bug. For now you can opt out of this behaviour by setting NOW_BUILDER to "" as pointed out by @dimitarnestorov above. Thanks everyone for having patience on this 🙌

Alright, dialed it back a notch. I just added a postinstall script on the backend to run prisma2 generate and got the same issue. Updated https://github.com/dimitarnestorov/next-prisma-monorepo

image

I’ve added the following to now.json and seems to be working with 2.0.0-preview019:

{
  "build": {
    "env": {
      "NOW_BUILDER": ""
    }
  }
}