Root `.env` variables aren't available to prisma in monorepo
See original GitHub issueBug description
We have a monorepo using turbo repo with the following structure:
The prisma package is being used in multiple applications, currently we’re trying to use a single .env
to avoid confusion. Moving the DATABASE_URL
url from packages/prisma/.env
to the root .env
errors when trying to run any yarn prisma script
.
We also tried to use a solution like cmd-env
:
But no luck so far.
How to reproduce
- Have a monorepo with and
.env
file at the root - Have something like
packages/prisma
in a monorepo package - Set
DATABASE_URL
in the root.env
file. - Try to run any
yarn prisma
command.
Expected behavior
Being able to use the monorepo DATABASE_URL
without having to set it up in packages/prisma/.env
.
Prisma information
https://github.com/calcom/cal.com/blob/main/packages/prisma/schema.prisma
Environment & setup
- OS: Mac OS 12
- Database: PostgreSQL
- Node.js version: v14.17.6
Prisma Version
prisma : 3.10.0
@prisma/client : 3.10.0
Current platform : darwin
Query Engine (Node-API) : libquery-engine 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine : migration-engine-cli 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary : prisma-fmt 73e60b76d394f8d37d8ebd1f8918c79029f0db86 (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : 73e60b76d394f8d37d8ebd1f8918c79029f0db86
Studio : 0.458.0
Issue Analytics
- State:
- Created a year ago
- Reactions:5
- Comments:5
Top Results From Across the Web
Environment variables - Prisma
Learn how to use environment variables in your Prisma project. ... Prisma creates a default .env file at your projects root. You can...
Read more >prisma - getting environment variable not found error message ...
If anybody running into this issue, just run npx prisma generate . This will re-establish the link between schema.prisma and .env file.
Read more >Using Prisma with Turborepo
Set up Prisma in a monorepo; Handle migration and code generation ... If you're using pnpm , you should add a file at...
Read more >Managing multiple environments in NestJS
Create the following structure in the root of your NestJS app. ... Another benefit is to provide defaults in case the env variables...
Read more >Building an Nx Prisma Generator - Sabin Adams - Hashnode
We will be able to access the Prisma Client using something like: ... generated variable in a .env file that all prisma schemas...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Awesome @leerob although I see you’re using symlinks to fix the “
.env
not it prisma root” problem. The thing is we only use this locally since we don’t actually deploy.env
files to prod. Wouldn’t this approach break in prod in this case?Related example: https://github.com/vercel/turborepo/tree/main/examples/with-prisma