Havvy
Havvy

Reputation: 1511

Call npm.info(modulename) without printing result to stdout

With a local installation of npm in ./node_modules/npm and inside a default node shell,

var npm = require('npm');
npm.load({}, function (err, res) {
    npm.info('tennu');
}

the result of npm.info() will echo to stdout the same stuff that it would as if you called

npm info tennu

from the commandline.

How can I make npm not echo to stdout?

Upvotes: 0

Views: 54

Answers (1)

isaacs
isaacs

Reputation: 17160

See npm apihelp info

require('npm').load({}, function (err, npm) {
    npm.commands.info(['tennu', 'version'], true, function (er, info) {
        console.error('the info was:', info)
    })
})

Upvotes: 2

Related Questions