3

In my project, I am trying to install prisma inorder to make a serverless function for registering with a mysql database (which located locally on my pc). So I follow these steps:

npm install prisma --save-dev
npx prisma init

After that a prisma folder was created inside my project with scheme.prisma, I changed it to this:

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

And changed .env to this:

DATABASE_URL="mysql://root:Mysqlpass@localhost:3306/mytable"

Now I ran this command "prisma db pull" and it changed my prisma.scheme file accordingly:

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

model users {
  username String @id @db.VarChar(12)
  email    String @unique(map: "email") @db.VarChar(254)
  password String @db.VarChar(24)
  date     String @db.VarChar(255)
}

If I run the command "netlify dev" the project works well with no errors. However, the moment I move to the next step which is creating the prisma client with "prisma generate" it does seem to work at first:

Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma

✔ Generated Prisma Client (v5.4.1) to .\node_modules\@prisma\client in 104ms

Start using Prisma Client in Node.js (See: https://pris.ly/d/client)        

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

or start using Prisma Client at the edge (See: https://pris.ly/d/accelerate)

import { PrismaClient } from '@prisma/client/edge'
const prisma = new PrismaClient()

See other ways of importing Prisma Client: http://pris.ly/d/importing-client

BUT now when I run "netlify dev" I get this error:

◈ Netlify Dev ◈
◈ Ignored general context env var: LANG (defined in process)
◈ Injected .env file env var: MAPLE_CONTENTFUL_SPACE_ID     
◈ Injected .env file env var: MAPLE_CONTENTFUL_ACCESS_KEY   
◈ Injected .env file env var: RECAPTCHA_KEY
◈ Injected .env file env var: RECAPTCHA_CLIENT
◈ Injected .env file env var: ReCAPTCHA_LOCALHOST
◈ Injected .env file env var: DATABASE_URL
◈ Setting up local development server
◈ Starting Netlify Dev with Vite

> [email protected] dev
> vite


  VITE v4.4.7  ready in 2019 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
✔ Waiting for framework port 5173. This can be configured using the 'targetPort' property in the netlify.toml

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

◈ Failed to load function recaptcha: Cannot read from `C:/Users/playe/OneDrive/Documents/GitHub/MapleBGU/mapleBGU-react/node_modules/.prisma`: EISDIR: illegal operation on a directory, read
◈ Failed to load function register: Cannot read from `C:/Users/playe/OneDrive/Documents/GitHub/MapleBGU/mapleBGU-react/node_modules/.prisma`: EISDIR: illegal operation on a directory, read
◈ Failed to load function contentful: Cannot read from `C:/Users/playe/OneDrive/Documents/GitHub/MapleBGU/mapleBGU-react/node_modules/.prisma`: EISDIR: illegal operation on a directory, read

 »   Error: Netlify CLI has terminated unexpectedly
This is a problem with the Netlify CLI, not with your application.
If you recently updated the CLI, consider reverting to an older version by running:

npm install -g netlify-cli@VERSION

You can use any version from https://ntl.fyi/cli-versions.

Please report this problem at https://ntl.fyi/cli-error including the error details below.

NestedError: Cannot read from `C:/Users/playe/OneDrive/Documents/GitHub/MapleBGU/mapleBGU-react/node_modules/.prisma`: EISDIR: illegal operation on a directory, read
    at Module.createReadStream (file:///C:/Users/playe/AppData/Roaming/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:///C:/Users/playe/AppData/Roaming/npm/node_modules/netlify-cli/node_modules/cp-file/index.js:11:21)       
    at file:///C:/Users/playe/AppData/Roaming/npm/node_modules/netlify-cli/node_modules/p-map/index.js:141:20
Caused By: Error: EISDIR: illegal operation on a directory, read

  System:
    OS: Windows 10 10.0.19043
    CPU: (4) x64 Intel(R) Core(TM) i5-6600 CPU @ 3.30GHz
  Binaries:
    Node: 18.17.1 - C:\Program Files\nodejs\node.EXE
    npm: 9.6.7 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 117.0.5938.134
    Edge: Spartan (44.19041.1266.0), Chromium (118.0.2088.27)

I have 3 netlify serverless functions but none of them are using prisma yet and they are located inside "netlify-functions" folder. here is my netlify.toml file:

[build]
command = "npm run build"
publish = "dist"
functions = "netlify-functions/"

I was expecting to properly install Prisma with my Vite project and Netlify serverless functions. At first, I tried to completely uninstall Prisma and do it again but nothing happened. also tried to work with chatGPT on it but didn't manage to get by either.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.