Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Error: Module not found: Can't resolve 'net' when using postgres #634

Closed
christo8989 opened this issue Sep 21, 2023 · 3 comments
Closed

Comments

@christo8989
Copy link

christo8989 commented Sep 21, 2023

Provide environment information

  System:
    OS: macOS 13.0
    CPU: (8) arm64 Apple M1
    Memory: 1.07 GB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.18.0 - ~/.nvm/versions/node/v18.18.0/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 9.8.1 - ~/.nvm/versions/node/v18.18.0/bin/npm
    pnpm: 7.27.1 - /opt/homebrew/bin/pnpm

Describe the bug

iOS runs fine. But I get an issue with nextjs.

Error: Module not found: Can't resolve 'net'

[Import](https://nextjs.org/docs/messages/module-not-found) trace for requested module:
../../node_modules/postgres/src/index.js
../../packages/db/index.ts
../../packages/auth/index.ts
./src/app/_components/auth-showcase.tsx
./src/app/page.tsx
../../node_modules/next/dist/build/webpack/loaders/next-edge-ssr-loader/index.js?absolute500Path=&abs

Seems this is related to "use client" when used with postgres?

Link to reproduction

None

To reproduce

Replace the db with postgres.
Run yarn dev

Additional information

No response

@christo8989
Copy link
Author

Related? drizzle-team/drizzle-orm#753

@juliusmarminge
Copy link
Member

You're trying to use a Nodejs package on edge runtime. Remove the export const runtime = "edge" from all pages and api routes and you should be good

@christo8989
Copy link
Author

Nice. That did it.

There's a note in the README:

Note
The db package is preconfigured to use PlanetScale and is edge-ready with the database.js driver. If you're using something else, make the necesary modifications to the schema as well as the client and the drizzle config.

A light suggestion to include this potential update?

However, thank you very much. You saved me a ton of time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants