skip to Main Content

EDIT : Deleted dist and node_modules folder and ran the commands again. Worked

I have prisma nest js project with postgresql db.

I am getting the following error after running npm run start :

PrismaClientInitializationError: error: Environment variable not found: DATABASE_URL.
  -->  schema.prisma:13
   | 
12 |   provider = "postgresql"
13 |   url      = env("DATABASE_URL")
   | 

Validation Error Count: 1

Things I have tried and outputs :

npx prisma migrate dev --name init

output : Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "spotapp", schema "public" at "localhost:2345"

npx prisma generate

output :
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma

I have .env file at root

I am on macOS

2

Answers


  1. This might be related the the latest prisma release 5.16.0

    See https://github.com/prisma/prisma/issues/24634

    Try downgrading to 5.15.0.

    You can see your version by running npx prisma version

    Login or Signup to reply.
  2. The error says "Environment variable not found". Are you sure DATABASE_URL is spelt correctly in your .env? And are you sure the .env file is in the right place?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search