https://github.com/digitaledgeit/npm-cmd
An API to execute `npm` commands programmatically.
https://github.com/digitaledgeit/npm-cmd
Last synced: about 1 year ago
JSON representation
An API to execute `npm` commands programmatically.
- Host: GitHub
- URL: https://github.com/digitaledgeit/npm-cmd
- Owner: digitaledgeit
- Created: 2015-07-09T00:48:20.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-09-10T02:17:06.000Z (over 10 years ago)
- Last Synced: 2025-04-17T14:43:12.549Z (about 1 year ago)
- Language: JavaScript
- Size: 129 KB
- Stars: 3
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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 - optional
- `opts` is an object of key-value pairs - optional
- `opts.global` whether npm should install
- `opts.save` whether npm should save the packages to the `dependencies` key in `package.json`
- `opts.saveDev` whether npm should save the packages to the `devDependencies` key in `package.json`
- `opts.registry` the registry which npm should source package information from
- `done` 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 - optional
- `opts` is an object of key-value pairs - optional
- `done` 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