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.

Select the directory of where to generate the client?

See original GitHub issue

Problem

Consider two directories:

  • shared
  • project

My schema.prisma resides in the shared directory. There is also a package.json in the shared directory. I am trying to generate a client in the project directory from the schema.prisma file.

If i cd to project and do npx prisma generate --schema=../shared/prisma.schema then the client is built in shared, and not in project like I wanted.

Suggested solution

Add a flag to specify working directory of the generate command. Use the working directory to generate the client, only use the --schema flag to read the file but ignore it when deciding where to put the client.

Alternatives

(None)

Additional context

image

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
birgerspcommented, May 6, 2022

Thanks a lot for helping me out here!

It did work with mutple generators blocks, but I am now using a slightly different workaround as it suits our project better, using an env variable that I set before I invoke prisma generate:

generator client {
    provider = "prisma-client-js"
    output = env("PRISMA_OUT")
}

That way, I can do

export PRISMA_OUT=../../myproject/node_modules/@prisma/client
npx prisma generate

to generate the client for my myproject directory.

However I don’t think this is perfect, because the “shared” folder (under which the schema.prisma file resides) will then get its own set of packages in node_modules. And they are never used unless I do another prisma generate.

Personally I find it somewhat un-intuitive that prisma generate is using only the schema file location to determine where the client should be built. Would it not be more “normal” to use the current directory? Other cli tools I’ve ever encountered (e.g npm, protoc, gradle, tar) emit files at the current directory. So in comparison I wanted the client to be built at /home/birger/someweirddir I would either have to do

cd /home/birger/someweirddir
prisma generate --schema /home/birger/wherever-the-schema-is/schema.prisma

or use a flag (if the tool has one).

TL;DR, the workaround is fine but I think others might also find that they want to manually override where prisma generate emits its files.

1reaction
antoine-1commented, May 6, 2022

I think we have the same problem? Look here : #13164

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generating the client (Concepts) - Prisma
By default, Prisma Client is generated into the node_modules/.prisma/client folder, but you can specify a custom location. To generate and instantiate Prisma ...
Read more >
Making the code directory available to all thin client ... - IBM
On the code server, start Windows Explorer. · Select the directory on the code server that will be used to serve thin client...
Read more >
Create a directory of names, addresses, and other information
Go to Mailings > Start Mail Merge > Directory. Select recipients.
Read more >
ASP.Net Web Application Choose Client Side Directory
I have the requirement to allow a user to provide a local directory path via a UI in a web application so ...
Read more >
Selecting a public Outlook folder for client email
Note: If your firm is running Practice CS in a Virtual Office CS or Software as a Service (SaaS) environment, you cannot create...
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