I am going through my first node.js project. I\'ve installed mongodb, have a server.js file, and when I try to run it I get this error
module.js:340
thro
You can do either of two things to make it run :-
1) Install mongodb globally with below steps :-
a)npm install mongodb -g
b) Go to your app directory, where module.js is located and then run
npm link mongodb
Explanation :- When you install a package globally via npm, it is downloaded to global node_module folder. For me(Mac user), it's under /usr/local/lib/node_modules/mongodb. We link this to that directory from where you are trying to run module.js.
2) Another approach is to install mongodb locally, not globally via
npm install mongodb
After following either of these, you will be seeing node_modules --> mongodb folder under the 'module.js' directory, which means mongodb has been successfully installed.