Reputation: 3705
Bug description Hello, I am new to Prisma. I have been trying to access Prisma database with nextjs. And every time I try to use PrismaClient from @prisma/client in a nextjs page, I have been seeing this error.
./node_modules/@prisma/client/runtime/index.js:26236:39 Module not found: Can't resolve 'async_hooks' null
How to reproduce Steps to reproduce the behavior:
My Schema file
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model User {
id Int @default(autoincrement()) @id
email String @unique
name String
password String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
I created a migration and ran with the following commands
npx prisma migrate save --experimental npx prisma migrate up --experimental
Then I also run npx prisma generate
This is my register.tsx file where I am accessing the prisma client
import { useState } from "react";
import { useRouter } from "next/router";
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
interface RegisterProps {}
const Register: React.FC = ({}) => {
const router = useRouter();
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [name, setName] = useState("");
const submitHandler = async (e) => {
e.preventDefault();
try {
const user = await prisma.user.create({
data: {
email,
password,
name,
},
});
console.log(user);
router.push("/");
} catch (e) {
console.log(e);
}
};
return (
// my template goes here
);
};
export default Register;
After running this, I am getting this following error
/node_modules/@prisma/client/runtime/index.js Module not found: Can't resolve 'async_hooks' null
Expected behavior I expect this code to build my page first. But it fails to do so and shows me the error in the title.
Prisma information All of these information was included in the steps to reproduce part
Environment & setup OS: Ubuntu Database: MySQL Node.js version: 14.05 Prisma version: 2.11.0
Upvotes: 0
Views: 7545