Node.js node_modules interfering with each other

I have a weird problem with Node.js where node_module directories seem to be interfering with each other. I have the following file structure:

- node_modules
- User.js
- app
  - app.js
  - node_modules

So I have a node_modules in the top level directory as well as one inside the app directory. Each node_modules directory contains just a mongoose directory. The User.js file is a simple mongoose model:

exports.User = function() {
    var mongoose = require('mongoose');
    var Schema = mongoose.Schema;

    var UserSchema = new Schema({
        email:      { type: String },
        firstName:  { type: String },
        lastName:   { type: String },
    });

    mongoose.model("User", UserSchema);
    var User = mongoose.model("User");
    return User;
}();

The main app, app.js, looks like this:

var mongoose = require("mongoose");
mongoose.connect("mongodb://localhost:27017/crnapi");
require("../User").User.find(function(err, users) {
    if(err)
        console.log(err);

    console.log("here");
});

Nothing but connecting to mongo and finding a user. The problem I'm seeing is that the call to find() just hangs--the callback is never called.

However, if I remove inner node_modules directory (the one inside the app folder), it works fine. It's like the presence of the inner node_modules somehow screws up the workings of mongoose. I know I could put everything in the outer node_modules and just delete the inner one, but there are reasons for me to not do that.

Can anyone tell me what is going on here? Is there an debug mode I can run node or mongoose in that will tell me what it's getting hung up on?

The problem was that I was creating multiple instances of mongoose instead of creating a single one and having all the code use it. I solved this by moving the mongoose module into a high enough directory that all the code that uses mongoose could get access to the same one.