Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

base-npm

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base-npm

Base plugin that adds methods for programmatically running npm commands.

Source
npmnpm
Version
0.4.0
Version published
Weekly downloads
2.2K
-80.79%
Maintainers
2
Weekly downloads
 
Created
Source

base-npm NPM version NPM downloads Build Status

Base plugin that adds methods for programmatically running npm commands.

You might also be interested in base-bower.

Install

Install with npm:

$ npm install base-npm --save

Usage

var npm = require('base-npm');
var Base = require('base');
var app = new Base();
app.use(npm());

// install npm packages `micromatch` and `is-absolute` to devDependencies
app.npm.devDependencies(['micromatch', 'is-absolute'], function(err) {
  if (err) throw err;
});

API

.npm

Execute npm install with the given args, package names and callback.

Params

  • args {String|Array}
  • names {String|Array}
  • cb {Function}: Callback

Example

app.npm('--save', ['isobject'], function(err) {
  if (err) throw err;
});

.npm.install

Install one or more packages. Does not save anything to package.json. Equivalent of npm install foo.

Params

  • names {String|Array}: package names
  • cb {Function}: Callback

Example

app.npm.install('isobject', function(err) {
  if (err) throw err;
});

.npm.latest

(Re-)install and save the latest version of all dependencies and devDependencies currently listed in package.json.

Params

  • cb {Function}: Callback

Example

app.npm.latest(function(err) {
  if (err) throw err;
});

.npm.dependencies

Execute npm install --save with one or more package names. Updates dependencies in package.json.

Params

  • names {String|Array}
  • cb {Function}: Callback

Example

app.npm.dependencies('micromatch', function(err) {
  if (err) throw err;
});

.npm.devDependencies

Execute npm install --save-dev with one or more package names. Updates devDependencies in package.json.

Params

  • names {String|Array}
  • cb {Function}: Callback

Example

app.npm.devDependencies('isobject', function(err) {
  if (err) throw err;
});

.npm.global

Execute npm install --global with one or more package names.

Params

  • names {String|Array}
  • cb {Function}: Callback

Example

app.npm.global('mocha', function(err) {
  if (err) throw err;
});

.npm.exists

Check if one or more names exist on npm.

Params

  • names {String|Array}
  • cb {Function}: Callback
  • returns {Object}: Object of results where the key is the name and the value is true or false.

Example

app.npm.exists('isobject', function(err, results) {
  if (err) throw err;
  console.log(results.isobject);
});
//=> true

History

v0.4.0

  • adds global method for installing with the --global flag
  • adds exists method for checking if a package exists on npm
  • removes base-questions
  • removes askInstall method (moved to base-npm-prompt)

v0.3.0

  • improved instance checks
  • adds base-questions
  • adds dependencies method
  • adds devDependencies method

You might also be interested in these projects:

Contributing

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

Building docs

Generate readme and API documentation with verb:

$ npm install verb && npm run docs

Or, if verb is installed globally:

$ verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Jon Schlinkert

License

Copyright © 2016, Jon Schlinkert. Released under the MIT license.

This file was generated by verb, v0.9.0, on June 16, 2016.

Keywords

api

FAQs

Package last updated on 16 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts