Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

365
Vistas
How to use multiple .env files in Prisma?

I am working on a nestjs project using Prisma, and I want to use multiple .env files with Prisma. I follow the guide here. According to the guide, I add:

"migratetest:mysql": "dotenv -e .env.test -- npx prisma migrate dev",
"migratedev:mysql": "dotenv -e .env.development -- npx prisma migrate dev"

to my package.json. I run migratetest:mysql to load the .env.test file and do the migration. Then, I run start: dev to start the app. However, the Prisma said:

Error: error: Environment variable not found: DATABASE_URL.
  -->  schema.prisma:10
   | 
 9 |   provider = "mysql"
10 |    url      = env("DATABASE_URL")
   | 

It seems that it can not find the .env file in my project (based on the guide, there is no .env file, it should change to .env.test and .env.development)

here is my .env.test:

DATABASE_URL=mysql://root:123456@localhost:3306/test

here is my .env.development:

DATABASE_URL=mysql://root:123456@localhost:3306/dev

please help :)

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to tell every script you have to use dotenv cli, so your start:dev should look like this:

"start:dev": "dotenv -e .env.development nest start --watch",

However, for me it's not starting the compilation in watch mode, I'm still trying to debug this. Any ideas?

EDIT: I posted this and 2 minutes later I was able to solve my issue :D The final version of the script should look like this:

"start:dev": "dotenv -e .env.development -- nest start --watch",

Reason for the need of two dashes being explained in Prisma docs:

Note: dotenv doesn't pass the flags to the Prisma command by default, this is why the command includes two dashes -- before prisma, making it possible to use flags like --force, --schema or --preview-feature.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda