Module not found error with Drizzle Nextjs Hono Supabase

The Error
./node_modules/dotenv/lib/main.js:2:1
Module not found: Can't resolve 'path'
./node_modules/dotenv/lib/main.js:2:1
Module not found: Can't resolve 'path'
The issue is somewhere either in this file
import { Hono } from "hono";

import { db } from "@/db/drizzle";
import { accounts } from "@/db/schema";

const app = new Hono().get("/", async (c) => {
console.log("running accounts query");


const data = async () => {
try {
const dbFetch = await db
.select({
id: accounts.id,
name: accounts.name,
})
.from(accounts);
return dbFetch;
} catch (error) {
console.log("Error fetching data from DB", error);
}
// when I comment out the data function and replace what's being passed to c.json() with something fixed then there is no issue but when I just try to run this function even when its not being passed to c.json() then it throws the same error

};

return c.json({ data });
});

export default app;
import { Hono } from "hono";

import { db } from "@/db/drizzle";
import { accounts } from "@/db/schema";

const app = new Hono().get("/", async (c) => {
console.log("running accounts query");


const data = async () => {
try {
const dbFetch = await db
.select({
id: accounts.id,
name: accounts.name,
})
.from(accounts);
return dbFetch;
} catch (error) {
console.log("Error fetching data from DB", error);
}
// when I comment out the data function and replace what's being passed to c.json() with something fixed then there is no issue but when I just try to run this function even when its not being passed to c.json() then it throws the same error

};

return c.json({ data });
});

export default app;
This file may help @/db/drizzle.ts
import "dotenv/config";

import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";

const connectionString = process.env.DATABASE_URL!;

// Disable prefetch as it is not supported for "Transaction" pool mode
export const client = postgres(connectionString, { prepare: false });
export const db = drizzle(client);
import "dotenv/config";

import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";

const connectionString = process.env.DATABASE_URL!;

// Disable prefetch as it is not supported for "Transaction" pool mode
export const client = postgres(connectionString, { prepare: false });
export const db = drizzle(client);
1 Reply
Arjun
ArjunOP7mo ago
bump bump 2
Want results from more Discord servers?
Add your server