2

i need help! i have a nextjs application that was running smoothly.. all of a sudden (a few updates in the github code through the deploybot later) it gives me the following error: i do not know what to do as i am a newbie.

please help

Call Stack

TypeError: t.versions.node is undefined

<unknown>
node_modules\mongoose\dist\browser.umd.js (220:268)
<unknown>
node_modules\mongoose\dist\browser.umd.js (220:331)
r
node_modules\mongoose\dist\browser.umd.js (1:347)
<unknown>
node_modules\mongoose\dist\browser.umd.js (1012:0)
r
node_modules\mongoose\dist\browser.umd.js (1:347)
<unknown>
node_modules\mongoose\dist\browser.umd.js (1009:0)
r
node_modules\mongoose\dist\browser.umd.js (1:347)
<unknown>
node_modules\mongoose\dist\browser.umd.js (308:1393)
<unknown>
node_modules\mongoose\dist\browser.umd.js (425:34)
r
node_modules\mongoose\dist\browser.umd.js (1:347)
<unknown>
node_modules\mongoose\dist\browser.umd.js (756:0)
r
node_modules\mongoose\dist\browser.umd.js (1:347)
<unknown>
node_modules\mongoose\dist\browser.umd.js (973:1692)
<unknown>
node_modules\mongoose\dist\browser.umd.js (977:72)
r
node_modules\mongoose\dist\browser.umd.js (1:347)
<unknown>
node_modules\mongoose\dist\browser.umd.js (973:244)
r
node_modules\mongoose\dist\browser.umd.js (1:347)
<unknown>
node_modules\mongoose\dist\browser.umd.js (1:1150)
<unknown>
node_modules\mongoose\dist\browser.umd.js (1:1168)
<unknown>
node_modules\mongoose\dist\browser.umd.js (1:64)
<unknown>
node_modules\mongoose\dist\browser.umd.js (1:196)


  [1]: https://i.stack.imgur.com/tpbZY.png
alex
  • 49
  • 5

1 Answers1

0

Make sure that only server side code imports mongoose.

I had exactly the same error, because I specified interfaces in the same files with mongoose Schemas and Models. These files/interfaces were imported into React components in the client side of Next JS.

Solution was to move the interfaces in different files, so that mongoose was used only in server side code.

Related information How to best import "server-only" code in Next.js?

  • hi there, thanks for your reply.. i only use "import mongoose" in my model files and the db-connect file.. (added a screenshot in the problem description) is that what you mean? could you please specify how i could solve this .. i feel a bit lost. – alex Sep 10 '22 at 21:36
  • also .. i have managed to reuse an earlier commit to restore the site.. now it works in Dev-environment but not on the vercel deployment -.-' – alex Sep 10 '22 at 21:41
  • @alex That's a good first step. However, you also need to ensure those files are also only ever used in server-side code. – juliomalves Sep 11 '22 at 20:43
  • @juliomalves hi, can you please elaborate - as i wrote i am new to all of this and dont have anyone to ask directly .. i dont understand what you guys mean with only server-side code? the mongoose import is only in my db.js (https://i.stack.imgur.com/tpbZY.png) and the models.. where else would it be? Sorry if this should be self explanatory.. any help is appreciated.. thinking about just restarting the whole project without mongoose.. :/ – alex Sep 12 '22 at 20:49
  • @alex It's used in the models and in `utils/db.js`. Is that file only imported/used on server code? To be clear, I'm not implying this is what's causing the error, I was merely trying to explain what the answer was trying to convey (which may or may not solve your issue). – juliomalves Sep 12 '22 at 20:58
  • @juliomalves alright. so i checked all files that have "import db from utils/db" and double-checked with this: https://next-code-elimination.vercel.app/ to see if anything that looks like "db" arrives on the client side. and there is not.. except for my pages/api routes.. but that should be fine. So i guess one could say its all server side? Do you have any more ideas ? – alex Sep 14 '22 at 13:43