bil-fis
(林晚晚ss.)
February 3, 2025, 3:05pm
1
I use express in my api project and when i upload it to vercel, i received an error that can’t find module “bson”
Cannot find module ‘bson’
Require stack:
/var/task/node_modules/mongodb/lib/bson.js
/var/task/node_modules/mongodb/lib/admin.js
/var/task/node_modules/mongodb/lib/index.js
/var/task/db.js
/var/task/server.js
/var/task/___now_launcher.js
/var/runtime/index.mjs
Did you forget to add it to “dependencies” in package.json
?
system
(system)
February 3, 2025, 3:05pm
2
If you’re having trouble deploying an Express app, this guide can help.
You can also ask v0 for suggestions tailored to your own project setup.
pawlean
(Pauline P. Narvas)
February 3, 2025, 7:14pm
3
Hi, @bil-fis ! Welcome
We wrote this Express community post recently, hopefully it helps!
Getting started
Express.js is one of the most popular framework choices for building a backend using Node.js. If you are starting a new Express project and want to deploy it to Vercel, we recommend you to follow the Using Express.js with Vercel guide.
Common patterns
If you are coming from an existing project, we’ve put together this example repository to showcase the common development patterns for Express apps.
We recommend hosting your frontend application on a separ…
anshumanb
(Anshuman Bhardwaj)
February 4, 2025, 6:09am
4
Hi @bil-fis , welcome to the Vercel Community!
Can you confirm if you have the bson - npm package installed and mentioned in the package.json
file?
1 Like
bil-fis
(林晚晚ss.)
February 6, 2025, 10:35am
5
I’m sure that i add bson package to package.json
anshumanb
(Anshuman Bhardwaj)
February 6, 2025, 10:36am
6
Hi @bil-fis , thanks for confirming. If you need more help, please share your public repo or a minimal reproducible example . That will let us all work together from the same code to figure out what’s going wrong.
bil-fis
(林晚晚ss.)
February 6, 2025, 10:48am
7
anshumanb
(Anshuman Bhardwaj)
February 6, 2025, 11:03am
8
Hi @bil-fis , thanks for sharing your repository. The project structure doesn’t look correct to me for hosting on Vercel.
I recommend following this post about Express applications on Vercel.
1 Like