Netlify dev: Functions cannot be called in dev mode with Prisma: EISDIR

Hello guys.

I’m trying to start a local dev server for my development.
The nextJs framework itsself starts quite well. I can see and visit all pages.
While trying to call a netlify function I’m running into an Error:

NestedError: Cannot read from `[...]/beatraum/node_modules/.prisma`: EISDIR: illegal operation on a directory, read
    at Module.createReadStream (file:///[...]/npm/node_modules/netlify-cli/node_modules/cp-file/fs.js:21:9)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at copyFileAsync (file:///[...]/npm/node_modules/netlify-cli/node_modules/cp-file/index.js:11:21)
    at file:///[...]/npm/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/node_modules/p-map/index.js:141:20
Caused By: Error: EISDIR: illegal operation on a directory, read {
  nested: [Error: EISDIR: illegal operation on a directory, read] {
    errno: -4068,
    code: 'EISDIR',
    syscall: 'read'
  },
  errno: -4068,
  code: 'EISDIR',
  syscall: 'read',
  name: 'CopyFileError'
}

This error occurs regardlessly whether I start the functions server with netlify dev or netlify functions:serve.
I deployed the website to netlify and the functions can be accessed and work as well.

This is my netlify.toml

# example netlify.toml
[build]
 command = "npm run build"
 functions = "netlify/functions"
 publish = ".next"

[[plugins]]
 package = "@netlify/plugin-nextjs"

 ## Uncomment to use this redirect for Single Page Applications like create-react-app.
 ## Not needed for static site generators.
 #[[redirects]]
 #  from = "/*"
 #  to = "/index.html"
 #  status = 200

 ## (optional) Settings for Netlify Dev
 ## https://github.com/netlify/cli/blob/main/docs/netlify-dev.md#project-detection
[dev]
 framework = "next"
 
 command = "next dev -p 8080" # Command to start your dev server
 targetPort = 8080 # Port that the dev server will be listening on
 #  publish = "dist" # Folder with the static content for _redirect file

 ## more info on configuring this file: https://docs.netlify.com/configure-builds/file-based-configuration/

My package.json

{
  "name": "beatraum",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "export": "next export",
    "debug": "netlify dev --inspect"
  },
  "dependencies": {
    "@hapi/iron": "^7.0.0",
    "@netlify/functions": "^1.4.0",
    "@next/font": "13.1.6",
    "@prisma/client": "^4.9.0",
    "@types/node": "18.11.18",
    "@types/react": "18.0.27",
    "@types/react-dom": "18.0.10",
    "cookie": "^0.5.0",
    "eslint": "8.33.0",
    "eslint-config-next": "13.1.6",
    "netlify-dev-plugin": "^1.0.28",
    "next": "13.1.6",
    "passport": "^0.6.0",
    "passport-local": "^1.0.0",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-netlify-forms": "^1.3.3",
    "swr": "^2.0.3",
    "typescript": "4.9.5",
    "uuid": "^9.0.0"
  },
  "devDependencies": {
    "autoprefixer": "^10.4.13",
    "netlify-cli": "^12.10.0",
    "postcss": "^8.4.21",
    "prisma": "^4.9.0",
    "tailwindcss": "^3.2.4"
  }
}

I don’t find anything on the internet that helps me anymore.

Thank you for your help in advance!

can you share your site/slug please?

Hey SamO,
you can reach the site at beatraum.netlify.app

Could you share your entire log from terminal (from the point where you run netlify dev)?

Hey hrishikesch,
this is the full log:

$ netlify dev
◈ Netlify Dev ◈
◈ Injecting environment variable values for all scopes
◈ Ignored general context env var: LANG (defined in process)
◈ Injected site settings env var: DATABASE
◈ Ignored site settings env var: DATABASE_URL (defined in .env file)
◈ Injected .env file env var: DATABASE_URL
◈ Injected site settings env var: HOST
◈ Injected site settings env var: PASSWORD
◈ Injected site settings env var: PORT
◈ Ignored site settings env var: USERNAME (defined in process)
◈ Setting up local development server
Patching D:\Eigene Dateien\Github\beatraum\node_modules\next\dist\server\base-server.js
Done
Patching D:\Eigene Dateien\Github\beatraum\node_modules\next\dist\server\next-server.js
Done
◈ Starting Netlify Dev with custom config
ready - started server on 0.0.0.0:8080, url: http://localhost:8080
info - Loaded env from D:\Eigene Dateien\Github\beatraum.env
:heavy_check_mark: Waiting for framework port 8080. This can be configured using the ‘targetPort’ property in the netlify.toml
◈ Loaded function createUser http://localhost:8888/.netlify/functions/createUser.
◈ Loaded function findSomething http://localhost:8888/.netlify/functions/findSomething.
◈ Loaded function findUsers http://localhost:8888/.netlify/functions/findUsers.
◈ Loaded function loginUser http://localhost:8888/.netlify/functions/loginUser.
◈ Functions server is listening on 51082

┌─────────────────────────────────────────────────┐
│ │
│ ◈ Server now ready on http://localhost:8888
│ │
└─────────────────────────────────────────────────┘

◈ Loaded edge function next-dev
Request from ::1: GET /.netlify/functions/findSomething

C:\Users[…]\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\netlify-redirector\lib\redirects.js:1
var Module=typeof Module!=“undefined”?Module:{};var moduleOverrides=Object.assign({},Module);var arguments_=;var thisProgram=“./this.program”;var quit_=(status,toThrow)=>{throw toThrow};var ENVIRONMENT_IS_WEB=typeof window==“object”;var ENVIRONMENT_IS_WORKER=typeof importScripts==“function”;var ENVIRONMENT_IS_NODE=typeof process==“object”&&typeof process.versions==“object”&&typeof

[Huge ton of minified javascript code]

NestedError: Cannot read from D:/Eigene Dateien/Github/beatraum/node_modules/.prisma: EISDIR: illegal operation on a directory, read
at Module.createReadStream (file:///C:/Users/[…]/AppData/Roaming/npm/node_modules/netlify-cli/node_modules/cp-file/fs.js:21:9)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at copyFileAsync (file:///C:/Users/[…]/AppData/Roaming/npm/node_modules/netlify-cli/node_modules/cp-file/index.js:11:21)
at file:///C:/Users/[…]/AppData/Roaming/npm/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/node_modules/p-map/index.js:141:20
Caused By: Error: EISDIR: illegal operation on a directory, read {
nested: [Error: EISDIR: illegal operation on a directory, read] {
errno: -4068,
code: ‘EISDIR’,
syscall: ‘read’
},
errno: -4068,
code: ‘EISDIR’,
syscall: ‘read’,
name: ‘CopyFileError’
}

The lines "Request from ::1 … " are printed upon calling any function.

I also realized, that it doesn’t matter whether I use prisma client in my function or not.

I think it might come from a false bundling but I’m quite unsure.

Thanks in advance!

This usually happens when the Functions exits in a weird manner. But based on the error, it appears it could be due to some library you’re using.

Do you think you can provide a minimal reproduction as a repo for the issue?

I created the repo: GitHub - Binaeg/binaeg-netlify-functions: For debugging purposes

Let me know if you need anything in addition!

I tried your repo, but none of the 3 functions gave me the error that you got. I got errors, but none like yours. For findUsers I got:

The other two just failed with:

Am I missing something?

I removed the database url, so it’s okay that this function doesn’t work.
The others should return 500 if you do not pass any body. So I guess it’s the expected result…

I guess it is working at your place…

Any idea what could be missing at my pc?

Im using this node version:

$ node -v
v16.16.0

I tried to start it at two different pcs. Both didn’t work out.
Both run Windows 10

I get the same issue on Windows. Sounds like whichever libraries you’re using are incompatible with Windows. You might have to find out which one is the problem and contact them.

1 Like

Interesting…

Thank you very much! :heart:
At least i know the problem now!

Maybe it’s time to setup a linux environment :smiley:

I am getting this same error on Windows…

share your log and what you’ve tried. We also need your site name

I tried to run my functions locally, without netlify.toml, so was set to the default 8888 port with the /.netlify/functions/
In build version it works, but mine local not
I ran the command netlify functions:serve, but get this error:



But when I clicked on it, i get these errors…
My package.json:

My tsconfig.json

I am trying without netlify.toml
Also until I access some funnction url it appers this message:

After the exactly moment that I click, it crashes

Did you try to install WSL and start it with in the WSL console?

This is the only solution for me to start the local server.