Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

355
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda