mikemaccana mikemaccana - 3 months ago 10
Node.js Question

node - see what version of package is used during require()?

I have a node module without a

package.json
(which I'm trying to fix). The package uses
cheerio
and
superagent
:

var log = console.log.bind(console),
superagent = require('superagent'),
cheerio = require('cheerio');


These dependencies are pulled in from parent project or from global modules. How can I tell exactly what version of the package is being loaded?

Answer

just require the package.

var package = require('supertest/package.json');
console.log(package.version);