Using Prisma with Nuxt 4's new directory structure
So after switching to the new directory structure on Nuxt 4 I've had this issue where I'm getting following error when trying to use API point which needs prisma.
This is despite me having Prisma generated. As you can see in the directory structure on the picture.
I figured that this should be since api point in the server can't access the root anymore. However if I try to move the generated folder for example into the server or shared I get following error.
Any ideas how to move forward here?

3 Replies
Hi @ATL. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the provided knowledge sources, here’s what is relevant to your issue:
- With Nuxt 4’s new directory structure, the server/ directory is now at the project root, separate from the app/ directory. The server/ directory is where your API endpoints (such as those using Prisma) should reside. The new structure does not restrict server code from accessing the project root or node_modules by default, so Prisma’s generated client (typically in node_modules/@prisma/client) should still be accessible from server/api handlers, as long as your project is set up correctly and prisma generate has been run in the project root New Directory Structure.
- The error you’re seeing (
You should not need to move the Prisma generated client. Make sure you run
@prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
) usually means that either the Prisma client was not generated, or the code is not able to resolve the generated client from node_modules. Moving the generated folder into server/ or shared/ is not recommended and not necessary; Prisma expects its generated client to be in node_modules/@prisma/client.
- The EPERM error when trying to move the generated folder is a filesystem permission issue and not related to Nuxt’s directory structure.
Recommended steps:
1. Ensure you are running prisma generate
in your project root (where your package.json and node_modules are). This will generate the client in node_modules/@prisma/client.
2. Do not move the generated Prisma client. Your server/api code should import Prisma like this:
This works as long as node_modules is at the project root, which is the default and expected setup.
3. Check your project structure: Your nuxt.config.ts, node_modules, and server/ should all be at the root level, not inside app/. This matches the new Nuxt 4 structure New Directory Structure.
4. If you have a custom srcDir or have moved folders, ensure that node_modules is still at the root and accessible to server code. If you have changed the default structure, you may need to adjust your configuration, but by default, Nuxt expects node_modules at the root.
Summary:You should not need to move the Prisma generated client. Make sure you run
prisma generate
in the root, and that your server/api code imports from '@prisma/client' as usual. The new directory structure does not prevent access to node_modules from server code. The EPERM error is a filesystem issue and not related to Nuxt.
If you continue to have issues, double-check your project structure and permissions, and ensure you are not running your dev server or build process in a way that changes the working directory context for server code New Directory Structure.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@110720190056013824> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
So here's to show that issue persists after having run prisma generate again. You can see that I run generate successfully, then turn on the app and after navigating to page calling endpoint that needs prisma I get that error.
On the api point causing the error prisma client is imported and used as such: