Loader function is being executed on the client side #6848
-
I have the following code in root.tsx import {PrismaClient} from '@prisma/client';
export async function loader({request, context}: LoaderArgs) {
const prisma = new PrismaClient();
... and I get the following error |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Prisma should be exported from a *.server file. This is due to a side effect of importing prisma in the route file. For an example see https://remix.run/docs/en/main/tutorials/jokes#connect-to-the-database |
Beta Was this translation helpful? Give feedback.
-
The reason was it was being run on Oxygen server instead of Express js. node APIs are not available in the environment. |
Beta Was this translation helpful? Give feedback.
The reason was it was being run on Oxygen server instead of Express js. node APIs are not available in the environment.