prisma: missing `index-browser.js.map`
Bug description
Failed to parse source map from 'D:\test\test\node_modules\@prisma\client\runtime\index-browser.js.map' file: Error: ENOENT: no such file or directory, open 'D:\test\test\node_modules\@prisma\client\runtime\index-browser.js.map'
I don’t see index-browser.js.map in the specified path
PrismaClient is unable to run in this browser environment, or has been bundled for the browser (running in `unknown`).
If this is unexpected, please open an issue: https://github.com/prisma/prisma/issues
Error: PrismaClient is unable to run in this browser environment, or has been bundled for the browser (running in `unknown`).
If this is unexpected, please open an issue: https://github.com/prisma/prisma/issues
at Object.get (http://localhost:3000/static/js/bundle.js:1747:15)
at http://localhost:3000/static/js/bundle.js:687:12
at commitHookEffectListMount (http://localhost:3000/static/js/bundle.js:31009:30)
at commitPassiveMountOnFiber (http://localhost:3000/static/js/bundle.js:32502:17)
at commitPassiveMountEffects_complete (http://localhost:3000/static/js/bundle.js:32474:13)
at commitPassiveMountEffects_begin (http://localhost:3000/static/js/bundle.js:32464:11)
at commitPassiveMountEffects (http://localhost:3000/static/js/bundle.js:32454:7)
at flushPassiveEffectsImpl (http://localhost:3000/static/js/bundle.js:34339:7)
at flushPassiveEffects (http://localhost:3000/static/js/bundle.js:34291:18)
at commitRootImpl (http://localhost:3000/static/js/bundle.js:34250:9)
How to reproduce
Expected behavior
MySQL module table content must be rendered as html elements
Prisma information
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model attendance {
id Int @id @default(autoincrement())
sessionId Int
studentId Int
score Int
session session @relation(fields: [sessionId], references: [id], map: "Attendance_sessionId_fkey")
student student @relation(fields: [studentId], references: [id], map: "Attendance_studentId_fkey")
@@index([sessionId], map: "Attendance_sessionId_fkey")
@@index([studentId], map: "Attendance_studentId_fkey")
}
model module {
id Int @id @default(autoincrement())
title String
semester Int
code String
session session[]
student student[] @relation("moduletostudent")
}
model session {
id Int @id @default(autoincrement())
date DateTime @default(now())
group String
moduleId Int
attendance attendance[]
module module @relation(fields: [moduleId], references: [id], map: "Session_moduleId_fkey")
@@index([moduleId], map: "Session_moduleId_fkey")
}
model student {
id Int @id @default(autoincrement())
email String @unique(map: "Student_email_key")
phone Int @unique(map: "Student_phone_key")
parentPhone Int
parentEmail String
name String
course String
university String
level String
group String
attendance attendance[]
module module[] @relation("moduletostudent")
}
Environment & setup
Windows 11 mysql node v18.17.1
Prisma Version
prisma : 5.3.1
@prisma/client : 5.3.1
Current platform : windows
Query Engine (Node-API) : libquery-engine 61e140623197a131c2a6189271ffee05a7aa9a59 (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Schema Engine : schema-engine-cli 61e140623197a131c2a6189271ffee05a7aa9a59 (at node_modules\@prisma\engines\schema-engine-windows.exe)
Schema Wasm : @prisma/prisma-schema-wasm 5.3.1-2.61e140623197a131c2a6189271ffee05a7aa9a59
Default Engines Hash : 61e140623197a131c2a6189271ffee05a7aa9a59
Studio : 0.494.0
About this issue
- Original URL
- State: open
- Created 9 months ago
- Reactions: 3
- Comments: 16 (7 by maintainers)
I was able to reproduce this issue with the instructions I left above, and I can confirm that removing the source map annotation in the
@prisma/client/runtimeprevents the issue, as mentioned by @FominSergiy.Thanks for the additional information @FominSergiy. I think this is enough for us to attempt a reproduction. I can clearly see that Webpack’s source-map-loader is attempting to load a source map in your errors as well as in other reported errors. Additionally, I found that Nest.js is suggesting similar tools as part of their templates. Your analysis has shown that the source map name is read and then cannot be found.
For the reproduction, I’d base myself on our webpack test that we have in ecosystem-tests which bundles our
index-browser, and setup source-map-loader as per their documentation.To all of you, please do come forward with a reproduction if you can create one. Thanks.
@janpio for sure, let me try it out.
We have a mono repo.
In our application we use nestJs with prisma for our backend. In our nestJs app we rely on types generated by our prisma file (something similar to this: https://www.prisma.io/docs/concepts/components/prisma-client/advanced-type-safety#what-are-generated-types).
such types can imported in the backend by the following line.
For our frontend we use react, and we are not directly importing the prisma types (there is a workaround we do). But the point is, we don’t use the import statement
import { YourCustomType } from '@prisma/client';<- this would give us a warning mentioned in this issue.The warning mentioned in this issue comes from a webpack, during bundling process. There are two types of map files:
index.js-> code intended to be used inside a Node application.index-browser.js-> code intended to be used on the browser.It seems to me that Prisma is intended to be used inside a Node application, and when it is imported inside a browser-app (such a react app), even for a sake of getting a type, it tries to find a source map inside the
index-browser.jsfile, and throws a warnings because there is none?I wonder if the react server components are trying to address this issue? https://www.prisma.io/react-server-components
Hi, I’m seeing the warning as well. We just upgraded our project to “@prisma/client”: “5.5.2” from “@prisma/client”: “5.1.1”. The webpack warning is coming from our React application (“react”: “18.2.0”) when it is served locally. Here’s the error:
I reverted back to 5.1.1, ran migrate reset, and the warning went away.
We don’t run prisma in react BTW 😃. We just use the client generated data types to type our API results.
I hope that helps!
Hello again. The problem was my negligence. We’ve fixed the warning in our project. This was because a prisma client library was imported into a ui component where it shouldn’t have. I’ve fixed the import, the warning is gone.
Good on my side.