Skip to content

Simple API for globally installing or uninstalling one or more NPM packages.

License

Notifications You must be signed in to change notification settings

jonschlinkert/npm-install-global

Repository files navigation

npm-install-global NPM version NPM monthly downloads NPM total downloads Linux Build Status

Simple API for globally installing or uninstalling one or more NPM packages.

Install

Install with npm:

$ npm install --save npm-install-global

Install with yarn:

$ yarn add npm-install-global

Usage

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);
});

API

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 run
  • names {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;
});

History

v1.0.0

  • adds .global method, now used by the other methods

v0.1.1

About

Related projects

  • 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

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Building docs

(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 tests

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

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.6.0, on April 29, 2017.

About

Simple API for globally installing or uninstalling one or more NPM packages.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published