H
Hono5mo ago
! dotarjun

Module not found: Can't resolve 'path' with Hono Drizzle

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);
21 Replies
Nico
Nico5mo ago
What run-time are you using? Do you have dotenv installed properly?
! dotarjun
! dotarjun5mo ago
I'm using bun and yes I have dotenv installed
Nico
Nico5mo ago
For bun you don’t need dotenv and you use process.env or Bun.env directly I’m not sure if that will fix the issue
! dotarjun
! dotarjun5mo ago
nope
Nico
Nico5mo ago
To confirm you removed that import and dotenv package and it did not fix it?
! dotarjun
! dotarjun5mo ago
Yes I did that. But I ran into this
No description
Nico
Nico5mo ago
What is this running on?
! dotarjun
! dotarjun5mo ago
next js, ms edge, arch linux
Aditya Mathur
Aditya Mathur5mo ago
Wait so are you using Cloudflare libs in nextjs?
! dotarjun
! dotarjun5mo ago
I wasn't intending to I just did a basic installation
Aditya Mathur
Aditya Mathur5mo ago
Cloudflare libs will only work in cloudflare runtimes like cloudflare pages and workers. Which docs did you follow? Can you point me to them so that I can cross check if this is the issue I would suggest you to follow the vercel and nextjs docs for setting things up
! dotarjun
! dotarjun5mo ago
I did that and that runs into this issue now
! dotarjun
! dotarjun5mo ago
No description
! dotarjun
! dotarjun5mo ago
I followed the official supabase and drizzle docs
Aditya Mathur
Aditya Mathur5mo ago
Just install the crypto package that should resolve this Can you share the link?
! dotarjun
! dotarjun5mo ago
Man I'm honestly tired of all this. So sick of grinding and not getting a job and facing rejections daily. I don't even see the point in building this project cuz I know I still won't get hired Wait
! dotarjun
! dotarjun5mo ago
Drizzle ORM - Drizzle with Supabase Database
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Aditya Mathur
Aditya Mathur5mo ago
This is something outside my scope of work, but just relax and take a break. Everyone is low at some point, I am too on a daily basis (biggest con of being a programmer). Just try to remember what all have you accomplished and start with a fresh mind. Relax everything will turn out good in the end. I will go through these and check why these issues might have been occurring.
! dotarjun
! dotarjun5mo ago
Found the fix I was running it on edge which Supabase doesn't support. I changed it to nodejs and it worked
Aditya Mathur
Aditya Mathur5mo ago
Please mark this as solved, thank you
Want results from more Discord servers?
Add your server