Simple API for globally installing or uninstalling one or more NPM packages.
Install with npm:
$ npm install --save npm-install-global
Install with yarn:
$ yarn add npm-install-global
var npm = require('npm-install-global');
// easily install packages
npm.install('generate', function(err) {
if (err) return console.log(err);
});
// or remove outdated packages
npm.uninstall('yeoman', function(err) {
if (err) return console.log(err);
});
// or install only packages that don't already exist
npm.maybeInstall(['foo', 'bar'], function(err) {
if (err) return console.log(err);
});
Execute npm --global
with the given command and one or more package names. This is the base for install and uninstall.
Params
names
{String|Array}: One or more package names.cb
{Function}: Callback
Example
npm('install', 'verb', function(err) {
if (err) throw err;
});
Execute npm [cmd] --global
with one or more package names
.
Params
cmd
{String}: The command to runnames
{String|Array}: One or more package names.cb
{Function}: Callback
Example
npm.global('install', 'generate', function(err) {
if (err) throw err;
});
Execute npm install --global
with one or more package names
.
Params
names
{String|Array}: One or more package names.cb
{Function}: Callback
Example
npm.install('generate', function(err) {
if (err) throw err;
});
Install the given packages if they are not already installed.
Params
names
{String|Array}: One or more package names.cb
{Function}: Callback
Example
npm.maybeInstall(['foo', 'bar', 'baz'], function(err) {
if (err) throw err;
});
Execute npm uninstall --global
with one or more package names
.
Params
names
{String|Array}: One or more package names.cb
{Function}: Callback
Example
npm.uninstall('yeoman', function(err) {
if (err) throw err;
});
v1.0.0
- adds .global method, now used by the other methods
v0.1.1
- adds .maybeInstall method
- base-npm: Base plugin that adds methods for programmatically running npm commands. | homepage
- base: Framework for rapidly creating high quality node.js applications, using plugins like building blocks | homepage
- generate: Command line tool and developer framework for scaffolding out new GitHub projects. Generate offers the… more | homepage
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Jon Schlinkert
Copyright © 2017, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on April 29, 2017.