Giter Site home page Giter Site logo

maxleiko.npmi's Introduction

npmi Build Status

NodeJS package that gives a simplier API to npm install (programatically installs things)

Installation

npm install npmi --save

Options

options.name

Type: String Optional: true

If you don't specify a name in options, but just a path, npmi will do the same as if you were at this path in a terminal and executing npm install
Otherwise, it will install the module specified by this name like npm install module-name does.

options.version

Type: String Optional: true Default 'latest'

Desired version for installation

options.path

Type: String Optional: true Default '.'

Desired location for installation (note that if you specified /some/foo/path, npm will automatically create a node_modules sub-folder at this location, resulting in /some/foo/path/node_modules). So don't specify the node_modules part in your path

options.forceInstall

Type: Boolean Optional: true Default false

If true, npmi will install options.name module even though it has already been installed.
If false, npmi will check if the module is already installed, if it is, it will also check if the installed version is equal to options.version, otherwise, it will install [email protected]

options.localInstall

Type: Boolean Optional: true Default false

Allows npmi to install local module that are not on npm registry. If, you want to install a local module by specifying its full path in options.name, you need to set this to true.

options.npmLoad

Type: Object Optional: true Default {loglevel: 'silent'}

This object is given to npm and allows you to do some fine-grained npm configurations.
It is processed by npm like command-line arguments but within an Object map (npm-config)

Usage example

var npmi = require('npmi');
var path = require('path');


var options = {
	name: 'your-module',	// your module name
	version: '0.0.1',		// expected version [default: 'latest']
	path: '.',				// installation path [default: '.']
	forceInstall: false,	// force install if set to true (even if already installed, it will do a reinstall) [default: false]
	npmLoad: {				// npm.load(options, callback): this is the "options" given to npm.load()
		loglevel: 'silent'	// [default: {loglevel: 'silent'}]
	}
};
npmi(options, function (err, result) {
	if (err) {
		if 		(err.code === npmi.LOAD_ERR) 	console.log('npm load error');
		else if (err.code === npmi.INSTALL_ERR) console.log('npm install error');
		return console.log(err.message);
	}

	// installed
	console.log(options.name+'@'+options.version+' installed successfully in '+path.resolve(options.path));
});

maxleiko.npmi's People

Contributors

maxleiko avatar

Watchers

James Cloos avatar Brenton House avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.