Next.js Discord

Discord Forum

Next.js 15 + Drizzle + Postgres.js: "Module Not Found: Can't Resolve 'net'" Error

Unanswered
Black carpenter ant posted this in #help-forum
Open in Discord
Black carpenter antOP
When configuring user data in a client component using actions.ts with Next.js 15, Drizzle ORM, and Postgres.js, the following error occurs:
Module not found: Can't resolve 'net'

This error originates from Postgres.js, which depends on Node.js built-in modules like net, tls, and crypto. The stack trace shows that the issue occurs when importing postgres in db/index.ts, affecting subsequent files like methods.ts and main page.

6 Replies

Black carpenter antOP
Tried using API routes too, still the same error.
Black carpenter antOP
somehow fixed by converting all server based functions to a seperate folder called server in src dir and editing next config
@Asian black bear Is this code in a client component?
Black carpenter antOP
no, the actions was a server component and was using actions in client to configure that
Asian black bear
Okay, so you're putting server actions in a client component
Black carpenter antOP
it's fixed now?