prismaprisma-graphql

prisma - getting environment variable not found error message when running graphql query


I am getting this error message from prisma when I am running the GraphQL query.

Environment variable not found: DATABASE_URL.\n  -->  schema.prisma:6\n   | \n 5 |   provider = \"postgresql\"\n 6 |   url      = env(\"DATABASE_URL\")\n   | \n\nValidation Error Count: 1",

At first, I didn't have the .env file in any of my project folders, then I added it with the link to the database url, still not working. Here is the folder structure:

The folder structure: in the root, there's node_modules, prisma and src folders, .env, .gitignore and package.json files. Inside prisma, there's a migrations folder and a schema.prisma file.

This is what I have inside my .env file looks like -

DATABASE_URL="postgres://postgres:mypassword@db.pqtgawtgpfhpqxpgidrn.supabase.co:5432/postgres"

Solution

  • If anybody running into this issue, just run npx prisma generate. This will re-establish the link between schema.prisma and .env file.