javascriptnode.jsmongodb

Cannot find module 'mongodb/node_modules/bson'


These are the statements I got after running the grunt serve command from the directory "sangam"

C:\Users\Rohit\Documents\GitHub\sangam>grunt serve
Running "serve" task

Running "clean:server" (clean) task

Running "env:all" (env) task

Running "concurrent:server" (concurrent) task

Running "injector:scripts" (injector) task
Missing option `template`, using `dest` as template instead
Injecting js files (14 files)
>> Nothing changed

Running "injector:css" (injector) task
Missing option `template`, using `dest` as template instead
Injecting css files (5 files)
>> Nothing changed

Running "wiredep:target" (wiredep) task

Running "autoprefixer:dist" (autoprefixer) task

Running "express:dev" (express) task
Starting background Express server
Debugger listening on port 5858
module.js:327
    throw err;
    ^

Error: Cannot find module 'mongodb/node_modules/bson'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (C:\Users\Rohit\Documents\GitHub\sangam\node_modules\mongoose\lib\drivers\node-mongodb-native\objectid.js:8:16)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)

Running "wait" task
>> Waiting for server reload...
Done waiting!

Running "open:server" (open) task

Running "watch" task
Waiting...

After running grunt serve, I get this error:

"cannot find module 'mongodb/node_modules/bson'" ,

The localhost page opens, but I get a "can't reach this page" error. How can I resolve it?


Solution

  • As written in the github-issue try doing following steps:-

    Make sure these two packages are at these versions

    "mongodb": "^2.1.16", "mongoose": "^4.4.12"

    npm install -g node-gyp 
    cd /to/your/project-folder
    rm -rf node_modules
    npm install
    

    Also try doing :-

    do npm install inside node_modules/mongodb.

    Hope this will help you.