Cannot find module './common' when hosting on vercel

Hey everyone,
I’ve got a web application that I’m trying to host on vercel. The front end works, but when I’m trying to run my server, I get an error. I believe the error is related to mongoDB in some way, because the error log says:

Cannot find module './common'
Require stack:
- /var/task/server/node_modules/debug/src/node.js
- /var/task/server/node_modules/debug/src/index.js
- /var/task/server/node_modules/mquery/lib/mquery.js
- /var/task/server/node_modules/mongoose/lib/query.js
- /var/task/server/node_modules/mongoose/lib/index.js
- /var/task/server/node_modules/mongoose/index.js
Did you forget to add it to "dependencies" in `package.json`?
Error: Runtime exited with error: exit status 1
Runtime.ExitError

I checked the files inside node_modules, and the only thing that I see that could potentially be an error is this:


I see this in every require statement in node_modules/mongoose. However, it seems to be a Typescript issue, and my project is Javascript, so I’m not sure this is what’s causing the problems. [It works locally, so it must be okay…]
I realize this may not be the appropriate place for this question, but I’ve been banging my head against the wall for a couple of days with this, and am very desperate at this point.

If you could please share any insights or guidance :cry:

Thank you!!

Hi @Sam_N_A1,

Welcome to the MongoDB Community!

Apologies for the late response.

Would you kindly verify whether all the necessary dependencies are correctly added to the package.json file? Also, please delete the ‘node_modules’ folder and then execute the npm i command. This will initiate the download of all the dependencies specified in the package.json file.

I suspect there may be a version compatibility issue. Please ensure that you are using the latest version of Mongoose. Additionally, I would advise reaching out to Vercel community or support for any environment-specific issues that might be causing this error in the deployment.

Regards,
Kushagra