-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
mongoose failing Next.js build — node_modules/mongoose/dist/browser.umd.js #13390
Comments
Have you tried the suggestion in this comment: #13252 (comment) ? |
@vkarpov15 Yes I have! I've added them both to my |
Are you explicitly importing Also, are you able to share a code sample that demonstrates this issue? |
I'm importing If you clone the repo I shared and just run GitHub repo: https://github.com/Infisical/infisical-customer-portal |
Exaclty same issue and whenever you try to run the server using `- error node_modules\mongoose\lib\types\objectid.js (21:31) @ prototype
next version - 13.4.1 |
@sundaram2021 So actually my |
hey , @dangtony98 I have resolve the issue . but if you move to mongoose version 7.0.3 then it will work fine with the next 13.4.1 version hope it helps |
@sundaram2021 Unfortunately that didn't work for me but I'm sure it was right. I think my issue has something more to do with the separation of client and server-side code in Next.js. Thanks though! |
you can refer my repository https://github.com/sundaram2021/blog-typescript-fullstack i will be committing all the changes soon |
So I finally managed to resolve this issue! I had the correct base setup for adding mongoose to Next.js but my specific case used multiple mongoose connections, so many examples didn't apply to me. I ended up having to wrap my models with an async function, call the functions to get the models, and then make any queries/mutations. I'll probably end up writing a blog about this since it was quite frustrating. |
It looks like @dangtony98 's repo is no longer public and I'm unable to repro using @sundaram2021 's repo. I cloned https://github.com/sundaram2021/blog-typescript-fullstack, changed Mongoose version to 7.1.1, tested with both
|
Hi @vkarpov15 I believe both @sundaram2021 and I have resolved the issue; we can close it now :) |
I dont't know what is the issue , it does not work with 7.1.1 version of mongoose but it with 7.0.3 , |
I'm facing this problem right now with nextjs, next auth 5.0.0-beta.13. |
@kurays015 please make sure you've followed the instructions on our Next.js docs. If you're still having trouble, please open a new issue with detailed repro instructions. |
can you provide your blog link |
Prerequisites
Mongoose version
7.1.0
Node.js version
18.12.1
MongoDB version
Atlas
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
12.0 — Monterey
Issue
When I run
npm run build
, I get the following error:While I was developing fine with
mongoose
andNext.js
usingnext dev
, I encountered this issue when building the application withnext build
. It'd be amazing if someone could help me out here.To reproduce this error, you can simply clone my repository here and start up the application; should take a few seconds to do that.
If you run
npm run dev
, then the app will startup fine and you can navigate to http://localhost:3000/auth/login.However, if you run
npm run build
, then you'll receive the error Failed to compile with the message in the above code block.The text was updated successfully, but these errors were encountered: