P
Prisma2mo ago
Jent

Problems with 6.18.0 in Next.js 16

Hi everyone, since I updated Prisma to version 6.18.0 in my Next.js 16 project, I’ve been having issues with the installation... I always run the same commands, but each time I get different errors: npm install prisma @prisma/client npx prisma init Then I configure the .env file with my database, and finally: npx prisma generate But every time I get errors... How can I fix this?
23 Replies
Prisma AI Help
Prisma AI Help2mo ago
You selected the carefully hand-crafted route. A dev artisan will respond soon. Meanwhile, the #ask-ai channel awaits if you're curious!
Aman
Aman2mo ago
What errors are you getting? 🤔 Try this examples - https://github.com/prisma/prisma-examples/tree/chore/fullstack-v7/orm/nextjs
GitHub
prisma-examples/orm/nextjs at chore/fullstack-v7 · prisma/prisma-e...
🚀 Ready-to-run Prisma example projects. Contribute to prisma/prisma-examples development by creating an account on GitHub.
Jent
JentOP2mo ago
Sometimes it says it can’t find the DATABASE_URL in the .env file (even though everything is configured correctly), other times I get errors with prisma.config.ts (various errors)... But again, I’ve always used Prisma and never had any issues — after updating to version 6.18.0, nothing works anymore...
Aman
Aman2mo ago
Do you have a repo to share?
Jent
JentOP2mo ago
https://github.com/gabriele-ferri/test-prisma Commands: npm create next-app@latest test-prisma cd test-prisma npm install prisma @prisma/client npx prisma init Change the .env DATABASE_URL and schema.prisma provider (for mysql) npx prisma db pull or npx prisma generate (same error): C:\Users\serve\Desktop\test-prisma>npx prisma db pull Failed to load config file "C:\Users\serve\Desktop\test-prisma" as a TypeScript/JavaScript module. Error: PrismaConfigEnvError: Missing required environment variable: DATABASE_URL npx prisma generate
GitHub
GitHub - gabriele-ferri/test-prisma
Contribute to gabriele-ferri/test-prisma development by creating an account on GitHub.
Jent
JentOP2mo ago
Complete error list
Jent
JentOP2mo ago
Tanks for help
Aman
Aman2mo ago
You repo is empty @Jent 🤔
Jent
JentOP2mo ago
Sorry I deleted for error, but I fixed the errors not using: npm install prisma npx prisma init and deleting: prisma.config.ts It’s correct?
Aman
Aman2mo ago
you can delete prisma.config.ts its fine You load the env you need to add a package like dotenv to load the env from teh .env add import "dotenv/config" on top of the file (prisma.config.ts)
Jent
JentOP2mo ago
But now I can't generate prisma generated Before prisma update I only run: npm install prisma @prisma/client npx prisma init (configure .env file and schema.prisma provider) npx prisma db pull npx prisma generate Why now it doesn't work? I reupload the repo so you can see
Jent
JentOP2mo ago
GitHub
GitHub - gabriele-ferri/test-prisma-2
Contribute to gabriele-ferri/test-prisma-2 development by creating an account on GitHub.
Jent
JentOP2mo ago
Now i used only: npm install prisma --save-dev npx prisma init --datasource-provider mysql --output ../generated/prisma imported "dotenv/config" in schema.prisma and updated the .env DATABASE_URL then: npx prisma db pull npx prisma generate and seems it works! So I don't have to install @prisma/client??? Thanks
nicolae2
nicolae22mo ago
Why it should work?
Jent
JentOP2mo ago
It worked, I’ve always used it that way Now I have to do like this?
nicolae2
nicolae22mo ago
It seems like a soup to me... Only mixed commands with no sense...
Jent
JentOP2mo ago
I understand, it's the first time I'm using Prisma and I might have mixed things up a bit... I simply want to create a project with Next.js and add Prisma while having an existing MySQL database.
nicolae2
nicolae22mo ago
Sorry, I don't know how to help you. I have another problem with back-up the data and I saw your question. I wanted only to vent. Good luck in solving your problem!
Aman
Aman2mo ago
now with the new prisma.config.ts you need handle the env yourself prisma does not load the env automatically anymore You do need @prisma/client its a required dependency i believe your issue is selved now that you added dotenv 🤔
Batman
Batman2mo ago
Sorry to bother you like this. I am completely new at prisma, started today, having the same issue you have. My situation is exactly same as you with the same versions, ngl. you said ''imported 'dotenv/config' in schema.prisma'', in schema you can not add it though, that's what biome (formatter) saying! Currently I am following a video on yt to learn prisma (4 months old, but maybe recorded way before). He was using neon, ran the command, npx prisma db seed, where seed from prisma.config.ts was seed: tsx prisma/seed.ts, (the only line I added, though he added in the packages.json (this was not working for me). so he ran the command, and neon updated the tables, but for me i am stuck as you. I also used your commands, db pull and generate (when running db seed, i got this in the error to us generate and try again), but still neon table is not updated. Cant figure about the problem 😭.
Aman
Aman2mo ago
add import "dotenv/config" in prisma.config.ts no need to add it in schema.prisma prisma.config.ts is a new feature and it requires you to handle the env yourself for now you can delete the config file and everything will works the same
Batman
Batman2mo ago
I thinks the problem is related to version problem. I do not think, you can even import "dotenv/config" this to schema.prisma in the first place. And I do need to add that toprisma.config.ts , without that it can't even find DATABASE_URL for some reason. Just like you said, you need to handle the env stuff, that may be the reason. I even deleted the prisma.config.ts, but getting the same error. Tried npx prisma generate too as it was saying this for every error 😩. I believe the problem is related to the new prisma update. I have seen your repo on this. I was running same commands. But getting the same error over and over again. ERROR: An error occurred while running the seed command: Error: Command failed with exit code 1: tsx prisma/seed.ts I have tried ts-node, getting the same error. Also @Jent was also saying, ''imported "dotenv/config" in schema.prisma'', which does not make sense as you can not import anything like that on schema.prisma file.
Aman
Aman2mo ago
No you don't need to add dotenv in schema.prisma Only add dotenv in prisma.config.ts

Did you find this page helpful?