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 :)