prisma: Netlify serverless functions with prisma errors with `NestedError: Cannot read from 'PROJECT_PATH/netlify-serverless-functions/node_modules/.prisma': EISDIR: illegal operation on a directory, read`
Bug description
Error Name NestedError: Cannot read from ‘PROJECT_PATH/netlify-serverless-functions/node_modules/.prisma’: EISDIR: illegal operation on a directory, read
netlify.toml
[functions]
directory = "functions/"
[[redirects]]
from = "/api/*"
to = "/.netlify/functions/:splat"
status = 200
[dev]
targetPort = 5173
I found this to be a Prisma error when trying another npm package. It works perfectly on netlify functions.
How to reproduce
- Source code Github Repo
- Start the server
netlify dev
- Navigate to
/api/hello
- Error
NestedError: Cannot read from 'PROJECT_PATH/netlify-serverless-functions/node_modules/.prisma': EISDIR: illegal operation on a directory, read
Expected behavior
Expected /api/hello
to return users from the database. But unable to read the prisma module from the netlify functions.
Prisma information
// prisma/schema.prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(uuid())
name String
email String @unique
password String
}
// functions/hello.ts
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
export const handler = async (event, context) => {
const users = await prisma.user.findMany()
return {
statusCode: 200,
body: JSON.stringify(users),
};
};
Environment & setup
- OS: Windows
- Database: PostgreSQL
- Node.js version: 18.12.0
- netlify-cli: 12.0.11
Prisma Version
prisma : 4.5.0
@prisma/client : 4.5.0
Current platform : windows
Query Engine (Node-API) : libquery-engine 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine : migration-engine-cli 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary : prisma-fmt 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Format Wasm : @prisma/prisma-fmt-wasm 4.5.0-43.0362da9eebca54d94c8ef5edd3b2e90af99ba452
Default Engines Hash : 0362da9eebca54d94c8ef5edd3b2e90af99ba452
Studio : 0.476.0
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 1
- Comments: 15 (9 by maintainers)
I would say this is a bug in
netlify dev
that we can not do anything about, unfortunately. I fixed it by doing the steps described in https://github.com/prisma/prisma/issues/16021#issuecomment-1345664685 - maybe try those if they help for you. Maybe also try a differentoutput
value thanclient
- we recently learned that sometimes leads to problems.