You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When i try to use mongoose to connect to mongodb in server components it gives me an error:
TypeError: mongoose__WEBPACK_IMPORTED_MODULE_0___default(...).createConnection is not a function
Expected Behavior
It should not happen since it is inside server component, so it shouldn't import with webpack(web env), instead it should be import with default node env
To Reproduce
create server component
import mongoose inside it
write code to connect mongodb with mongoose
run nextjs
The text was updated successfully, but these errors were encountered:
ghost
added
the
bug
Issue was opened via the bug report template.
label
Feb 8, 2022
ghost
changed the title
Cannot connect to mongodb with rsc
Cannot connect mongodb inside rsc
Feb 8, 2022
Until recently, when using RSC, you were forced to use the web runtime. #34068 makes this globally switchable, included in the canary release for now. A per-page switch is coming soon.
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.
Run
next info
(available from version 12.0.8 and up)Binaries:
Node: 17.4.0
npm: 8.3.1
Yarn: 3.1.1
pnpm: N/A
Relevant packages:
next: 12.0.10
react: 18.0.0-rc.0
react-dom: 18.0.0-rc.0
What version of Next.js are you using?
12.0.10
What version of Node.js are you using?
17.4.0
What browser are you using?
Brave
What operating system are you using?
Windows
How are you deploying your application?
next dev
Describe the Bug
When i try to use
mongoose
to connect to mongodb in server components it gives me an error:TypeError: mongoose__WEBPACK_IMPORTED_MODULE_0___default(...).createConnection is not a function
Expected Behavior
It should not happen since it is inside server component, so it shouldn't import with webpack(web env), instead it should be import with default node env
To Reproduce
The text was updated successfully, but these errors were encountered: