NextJS 13 MongoDB Module not found: Can't resolve ********
Verify canary release
- [X] I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:54 PDT 2022; root:xnu-8792.41.9~2/RELEASE_X86_64
Binaries:
Node: 16.14.0
npm: 8.5.0
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 13.0.0
eslint-config-next: 13.0.0
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
Chrome 106.0.5249.119
How are you deploying your application? (if relevant)
Vercel
Describe the Bug
When I try to connect to MongoDB using a server component (layout.tsx for example) I get:
Module not found: Can't resolve 'mongodb-client-encryption' in '/Users/armandodelavegaruiz/new-nuberti/app-client/node_modules/mongodb/lib'
Module not found: Can't resolve 'aws-crt' in '/Users/armandodelavegaruiz/new-nuberti/app-client/node_modules/@aws-sdk/util-user-agent-node/dist-cjs'
./node_modules/mongodb/lib/bson.js
Module not found: Can't resolve 'bson-ext' in '/Users/armandodelavegaruiz/new-nuberti/app-client/node_modules/mongodb/lib'
./node_modules/mongodb/lib/deps.js
Module not found: Can't resolve 'kerberos' in '/Users/armandodelavegaruiz/new-nuberti/app-client/node_modules/mongodb/lib'
If I do the same thing using page/api/endpoint.ts it works fine.
Expected Behavior
Being able to consume MongoDB while using a server component.
Link to reproduction
https://codesandbox.io/s/intelligent-maria-e4m9v0?file=/app/layout.tsx
To Reproduce
Add MongoDB to a server component.
Facing the same issue, any update?
Closing as duplicate of https://github.com/vercel/next.js/issues/42277
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.