npm-cmd
v0.2.0
Published
An API to execute `npm` commands programmatically.
Downloads
66
Readme
npm-cmd
An API to execute npm
commands programmatically.
Installation
npm install --save npm-cmd
Usage
var npm = require('npm-cmd');
npm.install(['express', 'cookie-parser'], {save: true, cwd: '/tmp'}, function(err) {
if (err) {
console.log('Installation failed.');
} else {
console.log('Installation succeeded!');
}
});
API
Methods
.install(pkgs, opts, done)
Run npm install
where:
pkgs
is an array of packages to install - optionalopts
is an object of key-value pairs - optionalopts.global
whether npm should installopts.save
whether npm should save the packages to thedependencies
key inpackage.json
opts.saveDev
whether npm should save the packages to thedevDependencies
key inpackage.json
opts.registry
the registry which npm should source package information fromdone
is a function called when the command has finished - optional
.dedupe(pkgs, opts, done)
Run npm dedupe
where:
pkgs
is an array of packages to dedupe - optionalopts
is an object of key-value pairs - optionaldone
is a function called when the command has finished - optional
Options
Global options accepted by all commands:
opts.cwd
is the directory where the command will be run