question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Postinstall hook fails with custom location for schema.prisma

See original GitHub issue

Bug description

When you have schema.prisma at a non-default location, like db/schema.prisma, then running npm install results in a scary error message that confuses users.

> @prisma/client@2.1.3 postinstall /private/tmp/a1/node_modules/@prisma/client
> node scripts/postinstall.js

Error: Either provide --schema or make sure that you are in a folder with a schema.prisma file.

How to reproduce

  1. Move schema.prisma to non-default location
  2. Delete node_modules
  3. Run npm i
  4. See error

Expected behavior

I’m not sure the best solution here, but at the very least this error message should be downgraded to info or warning and remove the terminal colors (currently bright red).

In Blitz we automatically generate prisma client as part of blitz build or blitz start, so usually Blitz users never have to think about this.

Environment & setup

@prisma/cli          : 2.1.3
Current platform     : darwin
Node: 12.6.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
pantharshit00commented, Jul 7, 2020

I am marking this as an improvement for now as behavior is confirmed but it is not breaking.

0reactions
timsuchanekcommented, Jul 20, 2020

Thanks for reporting @flybayer! It for sure makes sense to not error in the postinstall script, but only when executing prisma generate directly.

For all the cases that a schema could not be found, we now have this warning: image

If the schema was invalid or any other error caused the generation to fail, we have this info: image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generating the client (Concepts) - Prisma
This hook invokes the prisma generate command which in turn generates the Prisma Client code into the default location node_modules/. prisma/client .
Read more >
How To Build a GraphQL API with Prisma and Deploy to ...
In this tutorial, you'll build a GraphQL API for a blogging application in JavaScript using Node.js. You will first use Apollo Server to ......
Read more >
Command Line - Keystone 6 Documentation - KeystoneJS
The postinstall command will warn you if any of the generated files you should have committed to source control (such as the Prisma...
Read more >
prisma/client did not initialize yet. Please run "prisma generate ...
I usually don't use docker for this while developing, but I have this issue every time I change something in my schema.prisma and...
Read more >
Command Line Interface | RedwoodJS Docs
install, Appends DataMigration model to schema.prisma , creates api/db/dataMigrations directory. up, Executes outstanding data migrations ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found