Next.js Discord

Discord Forum

Can't get Prisma migrate to read my env variables

Answered
Ichneumonid wasp posted this in #help-forum
Open in Discord
Ichneumonid waspOP
I have my project connected to vercel and on that project I connected a postgres db. I did a Vercel Pull and I have all my env variables into .env.development.local. I have created a schema.prisma file as following:
// schema.prisma

generator client {
    provider = "prisma-client-js"
}

datasource db {
    provider  = "postgresql"
    url       = env("POSTGRES_PRISMA_URL") // uses connection pooling
    directUrl = env("POSTGRES_URL_NON_POOLING") // uses a direct connection
}

... Model definitions below ...

When I do "npx prisma migrate dev" I get the error "Environment variable not found: POSTGRES_PRISMA_URL."

However that variable is set in the .env.development.local file as POSTGRES_PRISMA_URL="<THE URL HERE>".

I have no idea. I have also tried pasting the env variables in .env.local as well but I get the same error.

(Btw, when I print my env variables in my code they get displayed correctly. When I do "echo %POSTGRES_PRISMA_URL%" in CMD I get nothing displayed)
Answered by Ichneumonid wasp
Apparently there is an issue with Prisma only reading from the .env file and no other env file (such as .env.local or .env.development.local etc.)

There is a relevant issue opened here https://github.com/prisma/prisma/issues/11050
View full answer

1 Reply

Ichneumonid waspOP
Apparently there is an issue with Prisma only reading from the .env file and no other env file (such as .env.local or .env.development.local etc.)

There is a relevant issue opened here https://github.com/prisma/prisma/issues/11050
Answer