mongoose: Error: Cannot find module 'mongodb/node_modules/bson'
I have this error since starting to develop with Mongoose 1,5 years ago.
The error never vanished completely, it comes back after each and every npm update
This error has been a friend and annoyance alongside the road developing with MEANB.
Are there any plans to finally get rid of this error or will it continue to annoy the developer community until the end of all time 😃?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 38 (3 by maintainers)
Had to npm install inside node_modules/mongodb.
Thanks for the help!
Well that’s fairly obvious. 😃 Even then though, this issue is ultra annoying. I don’t see how a package like mongoose, which is used by thousands upon thousands of devs and projects, and backed by Automattic, can’t get this shit sorted out. If there are strict requirements for versions, then PUT IT IN THE SHITTY DOCUMENTATION ON THE VERY FIRST PAGE.
Google searching this issue finds about 5 pages of results of people asking the same damned question! And there is no definitive answer!!!
Hi. Change to
mongoose 4.2.9
in yourpackage.json
. it works for me.This is still a bug in like every damn version of this package, you can’t use it with Node 6.x, you can’t use any version prior to 4.x without it breaking and showing this error, what is going on here? Why is there not documented Readme notes?
On Linux:
On OSX:
…then:
Works like a charm.
npm install mongoose@3.8.12
i actually fix it with @BradZzz 's comment
@molekilla have you tried
rm -rf node_modules && npm install
? And yes, mongoose works in node v6 just fine.Upgrading to the latest version of Mongoose and MongoDB worked for me. Though it did take some time to go through all the Mongoose changes in 4.x compared to 3.x!
Don’t use 3.9.7. It’s deprecated in npm for a reason: it was an unstable dev release from back when mongoose used to use linux kernel version numbering rather than semver. Use 3.8.x or 4.x.