I would move the dependency finding piece to its own file (with tests) as a private module.

You should also handle [peerDependencies](http://blog.nodejs.org/2013/02/07/peer-dependencies/)