THE MASTER
THE MASTER
DTDrizzle Team
Created by THE MASTER on 1/9/2024 in #help
Module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins
my src/lib/supabase/db.ts file looks like thsi :
import {drizzle} from "drizzle-orm/postgres-js";
import postgres from "postgres";
import * as schema from "../../../migrations/schema";
import {migrate} from "drizzle-orm/postgres-js/migrator";
if (!process.env.DATABASE_URL) {
console.log('Cannot find database url')
}
const client = postgres(process.env.DATABASE_URL as string, {max:1});
const db = drizzle(client, { schema });
const migrateDb = async () => {
try {
console.log("🟠 migrating db");
await migrate(db,{ migrationsFolder : "migrations"});
console.log("🟢 migrated db");

} catch (error) {
console.log("🔴 failed to migrate db",error);
}
}
migrateDb();


export default db;
import {drizzle} from "drizzle-orm/postgres-js";
import postgres from "postgres";
import * as schema from "../../../migrations/schema";
import {migrate} from "drizzle-orm/postgres-js/migrator";
if (!process.env.DATABASE_URL) {
console.log('Cannot find database url')
}
const client = postgres(process.env.DATABASE_URL as string, {max:1});
const db = drizzle(client, { schema });
const migrateDb = async () => {
try {
console.log("🟠 migrating db");
await migrate(db,{ migrationsFolder : "migrations"});
console.log("🟢 migrated db");

} catch (error) {
console.log("🔴 failed to migrate db",error);
}
}
migrateDb();


export default db;
my app/page.tsx looks like this :
'use client'
import db from '@/lib/supabase/db'


export default function Home() {
console.log(db)
return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">

hello
</main>
)
}
'use client'
import db from '@/lib/supabase/db'


export default function Home() {
console.log(db)
return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">

hello
</main>
)
}
I am getting this error :
⨯ node:crypto
Module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
Import trace for requested module:
node:crypto
./node_modules/drizzle-orm/migrator.js
./node_modules/drizzle-orm/postgres-js/migrator.js
./src/lib/supabase/db.ts
./src/app/page.tsx
⨯ node:crypto
Module build failed: UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
Import trace for requested module:
node:crypto
./node_modules/drizzle-orm/migrator.js
./node_modules/drizzle-orm/postgres-js/migrator.js
./src/lib/supabase/db.ts
./src/app/page.tsx
i ve been stuck at this for hoursss. can someone check and help me pls. i am using nextjs 13.5.8 if i comment out the migration part of db.ts then It keeps saying that fs ,net , perf_hooks modules are not installed but I've instaleld them like a million times already!
3 replies