npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

npm-cli

v0.1.0

Published

Gives a simplier API to npm install (programatically installs stuffs)

Downloads

3,387

Readme

npmi Build Status

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

NPM

npmi versions scheme

  • ^1: uses npm@^2
  • ^2: uses npm@^3

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

console.log(npmi.NPM_VERSION); // prints the installed npm version used by npmi


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

Acknowledgements

This work has been done in the context of the HEADS Project
HEADS LOGO