Get a list of require()'d modules in a javascript module along with the names in module scope the module objects are assigned to.

npm install required-as
2 downloads in the last week
5 downloads in the last month

Get the names and paths of modules required in a given module:

> var required_as = require('./lib/required-as');
> required_as('tests/fixtures/module.js');
[ { name: 'net', source: 'net' },
  { name: 'self', source: './module.js' },
  { name: 'required_as',
    source: '../../lib/required-as.js' } ]

from the module:

var net = require('net');
var self = require('./module.js');
var required_as = require('../../lib/required-as.js');

var not_a_module = 3;
npm loves you