Prisma not reading .env variables

There was an issue I had recently. I was trying to push db schema to the database that is defined in .env file. But prisma cli was not able to locate .env file.

There’s a workaround to push your schema. Follow the instructions below.

First, you should install dotenv-cli package.

npm install -g dotenv-cli

Then trigger generate command.

npx prisma generate

Now you can tell cli the filename of your .env file. For me it was .env.local

So I run the command below:

dotenv -e .env.local -- npx prisma db push

Leave a Reply

Your email address will not be published. Required fields are marked *