I have started working of late on MEAN technologies;
I have a module myModule. It has routes, services, models accessing database.
I have created another project, myAnotherModule in a separate directory, and have "npm link" ed it into myModule. While I try to use Mongoose in myAnotherModule, it is unable to access DB with proper credentials.
In the following code in myAnotherModule,
var db = mongoose.connection.db;
var mongoDriver = mongoose.mongo;
var gfs = new grid(db, mongoDriver);
it does not find the mongoose.connection.db
and db
is undefined.
Whereas if I use these lines in myModule, then the code works fine.
Why is myAnotherModule not able to find mongoose.connection.db
?
How does npm link work?
Try to connect following way :