mongoose: after the latest update I can't get mongoose to work neither on windows 8 or on the server

module.js:338
    throw err;
          ^
Error: Cannot find module 'mongodb/node_modules/mongodb-core/node_modules/bson/lib/bson/objectid'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (C:\Users\Pedro\Documents\mkt\node_modules\mongoose\lib\drivers\node-mongodb-native\objectid.js:9:16)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 21 (3 by maintainers)

Commits related to this issue

Most upvoted comments

That’s strange. Try doing an npm cache clear and a clean npm install rm -rf node_modules && npm install. What version of mongoose is this happening with?

That’s reasonable, we’ll investigate and see if we can find what’s causing this issue

@williamknn IIRC this was very specific to 4.0.2 for me. Looks like #2908 gets to the heart of the issue and the fix was in cb975db. Perhaps simply adding the appropriate bson version as a direct dependency of your project would fix it? Can’t remember enough about module resolution in node v6 at this time to say for sure, but it’s worth a quick experiment.