You may have installed mongodb in the wrong directory for your project. One good way to avoid such problems is to use the package.json file.
Create a directory for your node project and move your .js file into it. Add a file called package.json with this content:
{ "name": "application-name", "private": true, "dependencies": { "mongodb": ">=0.9.6-7", "mongoose": ">=0.0.1" } }
You can follow the pattern to add your other dependencies as needed.
Then run 'npm install' from this directory. It will install all the dependencies for your application. From there, your application should work fine.
source share