Replies: 30 comments 13 replies
-
Which package manager are you using?Package manager: Is your workspace a monorepo setup?Monorepo with Is a bundler in use? If yes, which one?Native Next.js bundler Is a framework in use? If yes, which one?Next.js Your project uses TypeScript or just JavaScript?TypeScript only When you saw our message, did it happen locally or in deployment?Locally Where is your project deployed?Not deployed yet How can we reproduce this?This is inside a type Props = {
params: {
brandId: string;
};
};
export async function GET(req: Request, { params: { brandId } }: Props) {
if (!brandId) {
return NextResponse.json(
{ error: "Brand ID is required" },
{ status: 400 }
);
}
const id = parseInt(brandId);
if (isNaN(id)) {
return NextResponse.json(
{ error: "Brand ID must be a number" },
{ status: 400 }
);
}
const discs = await prisma.disc.findMany({
where: {
brandId: id,
},
});
return NextResponse.json(discs);
} After a few rebuild and restarts, it seems to not always be happening on this given code. EDIT: Also happen when I used the Prisma adapter to next-auth and tried to use EDIT: I used generated client, and have switched to following Turorepos example, and have not had the same problems again in dev. Before the switch, I ran my app in build-mode, and did not experience this error in local build-run. |
Beta Was this translation helpful? Give feedback.
-
see #19564 (comment) / got here while trying to run prisma+sveltekit on fly.io |
Beta Was this translation helpful? Give feedback.
-
I got here from a Serverless project using
Other sections of the document have examples that led me to the above. |
Beta Was this translation helpful? Give feedback.
-
I just solved the same problem by following this solution. Thank you for sharing. |
Beta Was this translation helpful? Give feedback.
-
Do you mean |
Beta Was this translation helpful? Give feedback.
-
Im in the same spot using serverless-esbuild. Where did you put this?
|
Beta Was this translation helpful? Give feedback.
-
@wmlutz At the top level of the serverless config, e.g.
Note that this example is for the JS/TS version of it ( |
Beta Was this translation helpful? Give feedback.
-
I've only ever seen serverless.yml - so it took my brain a minute to figure it out crrobinson14, but I got it. And it's working! Thanks. |
Beta Was this translation helpful? Give feedback.
-
@crrobinson14 That you for the helpful comments. I continue to have the same issue where my deployed lambda is unable to find the schema.prisma. My structure is as follows:
I am able to build and the deploy the function that imports the db code from the package managed by Turborepo. However, when the js runs, it errors out with the unable to find schema.prisma error. Any help would be greatly appreciated. Happy to open source my repo current repo as well. |
Beta Was this translation helpful? Give feedback.
-
@aneurycasado You need to manually bundle the schema.prisma file. Since you have a monorepo and it's in a different directory Serverless is probably having trouble finding it. Maybe try adding a manual copy step to copy that file? The patterns block above is relative to the serverless folder, in your case |
Beta Was this translation helpful? Give feedback.
-
Thank you for the reply. I greatly appreciate it. I feel like I must be missing something with turborepo or the serverless build step. For now, I can probably create a bash script that moves this .prisma folder into the serverless app node modules folder. |
Beta Was this translation helpful? Give feedback.
-
Which package manager are you using?Package manager: npm Is your workspace a monorepo setup? Is a bundler in use? If yes, which one? Is a framework in use? If yes, which one? Your project uses TypeScript or just JavaScript?JavaScript When you saw our message, did it happen locally or in deployment?both Where is your project deployed?Not deployed yet How can we reproduce this?Download this project here |
Beta Was this translation helpful? Give feedback.
-
What error exactly are you getting?
This is from a sveltekit project that uses this adapter. The error above is from the lambda function that it deploys to AWS. We are migrating this project from knex (where these routes worked) to prisma. Which package manager are you using?pnpm@8.6.1 Is your workspace a monorepo setup?No, it's a standard sveltekit project layout Is a bundler in use? If yes, which one?vite@4.3.9 Is a framework in use? If yes, which one?sveltekit@1.20.4 Your project uses TypeScript or just JavaScript?TS@4.9.5 When you saw our message, did it happen locally or in deployment?When running local via 'pnpm run dev' the issue does not occur. When running local via 'pnpm run preview' the error message does not print, but all routes using prisma return a 403 error - no message is given in the console. Where is your project deployed?AWS via a cloudfront + s3 + api gateway + lambda configuration. How can we reproduce this?I will try and put together a reproduction repo tomorrow, but I suspect all you'd need to do is use sveltekit + prisma in preview. |
Beta Was this translation helpful? Give feedback.
-
I ran into this same error My project uses Webpack My
I had to update it to this to fix the error:
Has there been a change in the path prisma looks for the schema and binary in the upgrade from 4 -> 5? It might be worth adding that to the upgrade docs if so |
Beta Was this translation helpful? Give feedback.
-
What error exactly are you getting? When my app is starting up in ECS from an ECR-hosted docker image, I get this error. I don't get it when I build and run the docker image locally.
Which package manager are you using? Is your workspace a monorepo setup? Is a bundler in use? If yes, which one? Is a framework in use? If yes, which one? Your project uses TypeScript or just JavaScript? When you saw our message, did it happen locally or in deployment? Where is your project deployed? How can we reproduce this?
Here's one of the
The one difference between local and remote that I haven't tried yet is I run locally with the |
Beta Was this translation helpful? Give feedback.
-
This may help anyone using either of the below tutorials/repos: https://isidoro-ferreiro.medium.com/share-your-prisma-client-across-projects-44d1c7aca6fd Adding a symbolic link between from An alternative fix that would accomplish the same result would be to run the following from the repo that's consuming the external package: This will apply a small path fix to the external package to the external package. This could also be saved with patch-package to compare what specifically is changing and reapplied during CI/CD during package publishing. However, this is a very bad hack and seems to be a pattern one that Prisma unfortunately follows in a number of scenarios. Key take away: Prisma is very mono-repo centric. The prisma documentation suggests & points to this. Prisma really needs some runtime options or config option to override and/or append to the schema paths so it can be packaged as an external package in NPM packages, Github Private Packages, lerna repo, etc. At the moment, it requires the above generate command as a hack to keep paths in sync, which is completely against DRY principles. |
Beta Was this translation helpful? Give feedback.
-
What error exactly are you getting? [Nest] 186292 ERROR [ExceptionHandler] Prisma Client could not find its `schema.prisma`. This is likely caused by a bundling step, which leads to `schema.prisma` not being copied near the resulting bundle. We would appreciate if you could take the time to share some information with us.
Please help us by answering a few questions: https://pris.ly/bundler-investigation-error
PrismaClientInitializationError: Prisma Client could not find its `schema.prisma`. This is likely caused by a bundling step, which leads to `schema.prisma` not being copied near the resulting bundle. We would appreciate if you could take the time to share some information with us.
Please help us by answering a few questions: https://pris.ly/bundler-investigation-error
at new Dt (app\dist\apps\auth\main.js:361:118)
at PrismaService.getEngine (app\dist\apps\auth\main.js:385:5173)
at new t (app\dist\apps\auth\main.js:385:4737)
at new PrismaService (app\dist\apps\auth\main.js:915:9)
at Injector.instantiateClass (app\node_modules\@nestjs\core\injector\injector.js:358:19)
at callback (app\node_modules\@nestjs\core\injector\injector.js:59:45)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at Injector.resolveConstructorParams (app\node_modules\@nestjs\core\injector\injector.js:139:24)
at Injector.loadInstance (app\node_modules\@nestjs\core\injector\injector.js:64:13)
at Injector.loadProvider (app\node_modules\@nestjs\core\injector\injector.js:91:9) Which package manager are you using?
Is your workspace a monorepo setup? Is a bundler in use? If yes, which one? Is a framework in use? If yes, which one? Your project uses TypeScript or just JavaScript? When you saw our message, did it happen locally or in deployment? Where is your project deployed? How can we reproduce this? Add prisma, prisma/client and set
Create nestJS service and extend PrismaClient which imports from generated output PrismaClient
start nest app and error should occur |
Beta Was this translation helpful? Give feedback.
-
I would expect using a webpack bundler to import all assets it needs at bundle-time. I'm encountering the same issue, and found a fairly painless workaround. First the requested details: What error exactly are you getting?Here is the error message I receive after using Webpack to bundle a collection of transpiled JS files.
Which package manager are you using?
Is your workspace a monorepo setup?No. This is a collection of microservices, with 3 unique instances of Prisma. I saw the issue when deploying to an isolated remote server. The application is otherwise fine except for the error described above. Is your setup hosting multiple packages in a single workspace?Each of the projects has its own tsconfig.json, package.json, and webpack.config.js.
Do you prefer using TypeScript or JavaScript within your project, or both?When you saw our message, did it happen locally or in deployment?It does not happen locally, but in deployment. I would expect using the webpack bundler to import all assets it needs at bundle-time. Where is your project deployed?Digital Ocean droplet |
Beta Was this translation helpful? Give feedback.
-
To provide the deployed application a copy of the prisma.schema it desires, I just copied it from the dev env into the target environment as an additional file. Importantly, the relative path of bundle location to prisma.schema must be the same relative path as "entrypoint.ts" to prisma.schema. Here is the rsync step I am using now:
While this breaks the point of bundling to a single asset; it solves the problem for me now. |
Beta Was this translation helpful? Give feedback.
-
For the folks using Webpack + pnpm: It's been a few weeks since I resolved the issue on my end, so my memory is a bit fuzzy: I had a webpack resolve.alias key called resolve.alias: { @: path.resolve(/*...*/) } ^ This alias was conflicting with my attempts at copying over the new CopyWebpackPlugin({
patterns: [
{
from: `${path.dirname(require.resolve(`@prisma/client`))}`,
to: '.',
context: './',
},
{
from: `${path.dirname(require.resolve(`.prisma/client`))}`,
to: '.',
context: './',
},
],
}) When I changed my I'm also using node externals, which may play a part in your configuration: externals: [
{
_http_common: 'commonjs2 _http_common',
encoding: 'encoding',
},
nodeExternals({
allowlist: ['@prisma', '.prisma', /prisma/],
}),
], Hope this helps someone. Dependencies:
|
Beta Was this translation helpful? Give feedback.
-
What error exactly are you getting?
Which package manager are you using?NPM 9.6.7 Is your workspace a monorepo setup?yes Is a bundler in use? If yes, which one?i am not sure. it seems to be raycast: https://www.npmjs.com/package/@raycast/api?activeTab=readme Is a framework in use? If yes, which one?Raycast https://www.npmjs.com/package/@raycast/api?activeTab=readme Your project uses TypeScript or just JavaScript?TypeScript When you saw our message, did it happen locally or in deployment?deployment Where is your project deployed?as one extension, running on Raycast How can we reproduce this?follow instruction on https://developers.raycast.com/basics/create-your-first-extension to create one demo. directly using the prism will raise error |
Beta Was this translation helpful? Give feedback.
-
Ran into this Bundler error as well (clientVersion: '5.2.0'): What error exactly are you getting? Which package manager are you using? Is your workspace a monorepo setup? Is a bundler in use? If yes, which one? Is a framework in use? If yes, which one? Your project uses TypeScript or just JavaScript? When you saw our message, did it happen locally or in deployment? Where is your project deployed? How can we reproduce this? |
Beta Was this translation helpful? Give feedback.
-
What error exactly are you getting?
Which package manager are you using? Is your workspace a monorepo setup? Is a bundler in use? If yes, which one? Is a framework in use? If yes, which one? Your project uses TypeScript or just JavaScript? When you saw our message, did it happen locally or in deployment? Where is your project deployed? How can we reproduce this? |
Beta Was this translation helpful? Give feedback.
-
What error exactly are you getting?Prisma Client could not find its Which package manager are you using?npm v8.19.4 Is your workspace a monorepo setup?No, standard Sveltekit. Is a bundler in use? If yes, which one?vite v4.4.10 Is a framework in use? If yes, which one?Sveltekit Your project uses TypeScript or just JavaScript?TS When you saw our message, did it happen locally or in deployment?
Where is your project deployed?Azure static web app How can we reproduce this?Basically this example: https://lucia-auth.com/database-adapters/prisma/ |
Beta Was this translation helpful? Give feedback.
-
I'm currently trying to use Prisma with MeteorJS. Meteor bundles all html/css/js into a proprietary bundle that does not include other file types and so during the postinstall hook the schema file isn't found to be able to generate the client. Initially I figured no big deal, I'll just generate the client before hand and include it in application code, but upon trying that it seems that at runtime the prisma engine instantiation requires access the the schema file thus leading me to this discussion thread. This leaves me questioning, is it really necessary to read the schema file at runtime? Don't we already go through a generation step that uses the schema? If needed for something at runtime couldn't this be generated as a JS object that could be included in the bundle rather than trying to read the schema from an assumed environment that might not exist? If you'd like to explore further, you can create a new meteor project with |
Beta Was this translation helpful? Give feedback.
-
Which package manager are you using? Package manager: yarn Is your workspace a monorepo setup? Is a bundler in use? If yes, which one? Is a framework in use? If yes, which one? Your project uses TypeScript or just JavaScript? When you saw our message, did it happen locally or in deployment? Where is your project deployed? How can we reproduce this? datasource db {
provider = "postgresql"
url = env("URLS_FROM_ENV_VARS")
}
generator client {
provider = "prisma-client-js"
// first schema
output = "../../src/prisma/prisma-core/js-client"
// second schema
output = "../../src/prisma/prisma-logs/js-client"
} I tried build project using webpack then run. After debug I found that prisma tries to access a file EDIT: My Folder structure
EDIT: It doesn't matter which output I put. Every time it refers to 2 directories up. like ignoring |
Beta Was this translation helpful? Give feedback.
-
I'll keep it brief because i'm in a rush, but hoping this might help: in nx monorepo changing
to
means that the .node files aren't within node_modules and don't get bundled (i think). when using the "generatePackageJson": true in an app or libs project.json, and building, dist/app/my-app/package.json is generated and includes a subset of the monorepos package.json deps. however it misses the .node files. previously i've just copied node_modules/.xxx to the node_modules in my docker image. (the '.' prefix avoids npm install etc from wiping from node_modules). However not sure how else to bundles these outside of node_modules. I wanted to avoid generating into node_modules for libs because it makes our nx CI/CD process more complex with nx affected, boundaries & caching etc. using nx-tools prisma plugin fwiw. |
Beta Was this translation helpful? Give feedback.
-
What error exactly are you getting?
Which package manager are you using? Is your workspace a monorepo setup? Is a bundler in use? If yes, which one? Is a framework in use? If yes, which one? Your project uses TypeScript or just JavaScript? When you saw our message, did it happen locally or in deployment? Where is your project deployed? |
Beta Was this translation helpful? Give feedback.
-
What error exactly are you getting?
Which package manager are you using?
Is your workspace a monorepo setup?no Is a bundler in use? If yes, which one?Is a framework in use? If yes, which one?
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'standalone',
experimental: {
esmExternals: false,
serverComponentsExternalPackages: ["mysql2", "mysqldump"],
},
};
module.exports = nextConfig; Your project uses TypeScript or just JavaScript?TypeScript When you saw our message, did it happen locally or in deployment?The message happens during a local deployment. Where is your project deployed?I am trying to deploy locally on my own laptop in a different folder, the application that I built. The ultimate goal is to deploy with pm2, but as a first step, I just execute: How can we reproduce this?So as said previously, the project is configured in standalone. The revelant scripts in my package.json are {
"scripts": {
"preinstall": "npx only-allow pnpm",
"postinstall": "prisma generate",
"dev": "next dev",
"build": "next build",
"start": "next start"
}
} I have a empty folder named "deploy" somewhere.
|
Beta Was this translation helpful? Give feedback.
-
What error exactly are you getting?
Which package manager are you using? Is your workspace a monorepo setup? Is a bundler in use? If yes, which one? Is a framework in use? If yes, which one? Your project uses TypeScript or just JavaScript? When you saw our message, did it happen locally or in deployment? Where is your project deployed? How can we reproduce this? I've created a detailed issue for the serverless team here, and while I think this is probably more to do with serverless-esbuild than prisma, it only happens for prisma (no other deps), so I figured I'd include a post in this thread as well |
Beta Was this translation helpful? Give feedback.
-
Hi, you have been directed to this issue because we want to learn more about your project setup. Thanks to your answers, we will be able to better take design decisions in the future.
We'd appreciate if you could take 5 minutes to answer a few questions for us. You can write your reply directly in this issue as a comment. Copy paste these questions in your answer, leave the answer blank if you don't know.
What error exactly are you getting?
Please share the error you are getting, and when exactly.
Which package manager are you using?
For instance
npm
,pnpm
, oryarn
. Please attach the version if you know it.Is your workspace a monorepo setup?
Is your setup hosting multiple packages in a single workspace?
Is a bundler in use? If yes, which one?
Are you using
webpack
,swc
,esbuild
,rollup
, or any other bundler?Is a framework in use? If yes, which one?
Are you using
Next.js
,Next
, or any other framework?Your project uses TypeScript or just JavaScript?
Do you prefer using TypeScript or JavaScript within your project, or both?
When you saw our message, did it happen locally or in deployment?
The message was "Please help us by answering a few questions".
Where is your project deployed?
Are you deploying to Vercel, Netlify, Lambda, or something else?
How can we reproduce this?
Could you please provide us with some code to reproduce this?
Beta Was this translation helpful? Give feedback.
All reactions