npminstall
Let npm install fast and easy
Last updated 8 years ago by dead_horse .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install npminstall 
SYNC missed versions from official npm registry.

npminstall

NPM version Node CI Test coverage Known Vulnerabilities npm download FOSSA Status

Make npm install fast and handy.

Node.js and Python required

  • Node.js >= 14.x
  • Python >= 3.x

Use as Cli

Install

$ npm install npminstall -g

Usage

In cnpm

It is integrated in cnpm.

$ npm install cnpm -g
# will use npminstall
$ cnpm install

npminstall

Usage:

  npminstall
  npminstall <pkg>
  npminstall <pkg>@<tag>
  npminstall <pkg>@<version>
  npminstall <pkg>@<version range>
  npminstall <alias>@npm:<name>
  npminstall <folder>
  npminstall <tarball file>
  npminstall <tarball url>
  npminstall <git:// url>
  npminstall <github username>/<github project>

Can specify one or more: npm install ./foo.tgz bar@stable /some/folder
If no argument is supplied, installs dependencies from ./package.json.

Options:

  --production: won't install devDependencies
  --save, --save-dev, --save-optional: save installed dependencies into package.json
  -g, --global: install devDependencies to global directory which specified in `$ npm config get prefix`
  -r, --registry: specify custom registry
  -c, --china: specify in china, will automatically using chinese npm registry and other binary's mirrors
  -d, --detail: show detail log of installation
  --trace: show memory and cpu usages traces of installation
  --ignore-scripts: ignore all preinstall / install and postinstall scripts during the installation
  --no-optional: ignore optionalDependencies during the installation
  --forbidden-licenses: forbit install packages which used these licenses
  --engine-strict: refuse to install (or even consider installing) any package that claims to not be compatible with the current Node.js version.
  --flatten: flatten dependencies by matching ancestors dependencies
  --registry-only: make sure that all packages are installed from registry. Any package that is installed from remote(e.g.: git, remote url) will lead to a failure of installation.
  --cache-strict: use disk cache even on production env

npmuninstall

Usage:

  npmuninstall <pkg>
  npmuninstall <pkg>@<version>
  npmuninstall <pkg>@<version> [<pkg>@<version>]
  npminstall <alias>@npm:<name>

npmlink

Usage:

  npmlink <folder>

Use as Lib

Install

$ npm install npminstall --save

Usage

const npminstall = require('npminstall');

(async () => {
  await npminstall({
    // install root dir
    root: process.cwd(),
    // optional packages need to install, default is package.json's dependencies and devDependencies
    // pkgs: [
    //   { name: 'foo', version: '~1.0.0' },
    // ],
    // install to specific directory, default to root
    // targetDir: '/home/admin/.global/lib',
    // link bin to specific directory (for global install)
    // binDir: '/home/admin/.global/bin',
    // registry, default is https://registry.npmjs.org
    // registry: 'https://registry.npmjs.org',
    // debug: false,
    // storeDir: root + 'node_modules',
    // ignoreScripts: true, // ignore pre/post install scripts, default is `false`
    // forbiddenLicenses: forbit install packages which used these licenses
  });
})().catch(err => {
  console.error(err);
});

Support Features

  • [x] all types of npm package
    • [x] a) a folder containing a program described by a package.json file (npm install file:eslint-rule)
    • [x] b) a gzipped tarball containing (a) (npm install ./rule.tgz)
    • [x] c) a url that resolves to (b) (npm install https://github.com/indexzero/forever/tarball/v0.5.6)
    • [x] d) a <name>@<version> that is published on the registry with (c)
    • [x] e) a <name>@<tag> (see npm-dist-tag) that points to (d)
    • [x] f) a <name> that has a "latest" tag satisfying (e)
    • [x] g) a <git remote url> that resolves to (a) (npm install git://github.com/timaschew/cogent#fix-redirects)
  • [x] All platform support
  • [x] global install (-g, --global)
  • [x] preinstall, install, postinstall scripts
  • [x] node-gyp@9, only support Python@3
    • [x] node-pre-gyp
  • [x] bin (yo@1.6.0, fsevents@1.0.6)
  • [x] scoped package
  • [x] bundleDependencies / bundledDependencies (node-pre-gyp@0.6.19, fsevents@1.0.6)
  • [x] optionalDependencies (pm2@1.0.0)
  • [x] peerDependencies (co-defer@1.0.0, co-mocha@1.1.2, estraverse-fb@1.3.1)
  • [x] deprecate message
  • [x] --production mode
  • [x] save, save-dev, save-optional
  • [x] support ignore-scripts
  • [x] uninstall
  • [x] resolutions
  • [x] npm alias
  • [x] npm workspaces

Different with NPM

This project is inspired by pnpm, and has a similar store structure like pnpm. You can read pnpm vs npm to see the different with npm.

Limitations

  • You can't install from shrinkwrap(and don't want to support for now).
  • Peer dependencies are a little trickier to deal with(see rule 1 below).
  • You can't publish npm modules with bundleDependencies managed by npminstall(because of rule 2 below).
  • npminstall will collect all postinstall scripts, and execute them until all dependencies installed.
  • If last install failed, better to cleanup node_modules directory before retry.

node_modules directory

Two rules:

  1. The latest version of modules will link at options.storeDir's node_modules.
  2. Module's dependencies will link at module's node_modules.

e.g.:

  • app: { "dependencies": { "debug": "2.2.0" } } (root)
  • debug@2.2.0: { "dependencies": { "ms": "0.7.1" } }
app/
├── package.json
└── node_modules
    ├── _debug@2.2.0@debug
    │   ├── node_modules
    │   │   └── ms -> ../../_ms@0.7.1@ms
    ├── _ms0.7.1@ms
    ├── debug -> _debug@2.2.0@debug
    └── ms -> _ms@0.7.1@ms # for peerDependencies

flattened vs nested

npminstall will always try to install the maximal matched version of semver:

root/
  koa@1.1.0
  mod/
    koa@~1.1.0
# will install two different version of koa when use npminstall.

you can enable flatten mode by --flatten flag, in this mod, npminstall will try to use ancestors' dependencies to minimize the dependence-tree.

root/
  koa@1.1.0
  mod/
    koa@~1.1.0

root/
  koa@1.1.0
  mod/
    koa@^1.1.0
# both the same version: 1.1.0

root/
  koa@~1.1.0
  mod/
    koa@^1.1.0
# both the same version: 1.1.2

root/
  mod/
    koa@^1.1.0
  moe/
    koa@~1.1.0
# two different versions

npminstall will always treat n.x and n.m.x as flattened

root/
  koa@1.1.0
  mod/
    koa@1.1.x
both the same version: 1.1.0

root/
  koa@~1.1.0
  mod/
    koa@1.x
both the same version: 1.1.2

Resolutions

support selective version resolutions like yarn. which lets you define custom package versions inside your dependencies through the resolutions field in your package.json file.

resolutions also supports npm alias. It's a workaround feature to fix some archived/inactive/ package by uploading your own bug-fixed version to npm registry.

see use case at unittest package.json.

Benchmarks

https://github.com/cnpm/npminstall-benchmark

cnpmjs.org install

  • npminstall@1.2.0
  • pnpm@0.18.0
  • npm@2.14.12
cli real user sys
npminstall 0m10.908s 0m8.733s 0m4.282s
npminstall with cache 0m8.815s 0m7.492s 0m3.644s
npminstall --no-cache 0m10.279s 0m8.255s 0m3.932s
pnpm 0m13.509s 0m11.650s 0m4.443s
npm 0m28.171s 0m26.085s 0m8.219s
npm with cache 0m20.939s 0m19.415s 0m6.302s

pnpm benchmark

see https://github.com/pnpm/pnpm#benchmark

npminstall babel-preset-es2015 browserify chalk debug minimist mkdirp
    real	0m8.929s       user	0m5.606s       sys	0m2.913s
pnpm i babel-preset-es2015 browserify chalk debug minimist mkdirp
    real	0m12.998s      user	0m8.653s       sys	0m3.362s
npm i babel-preset-es2015 browserify chalk debug minimist mkdirp
    real	1m4.729s       user	0m55.589s      sys	0m23.135s

License

MIT

Contributors


fengmk2


dead-horse


gemwuu


semantic-release-bot


killagu


ibigbug


vagusX


afc163


yesmeck


popomore


we11adam


whatwewant


emma-owen


weihong1028


HomyeeKing


nightink


XadillaX


LeoYuan


cnlon


Moudicat


hanzhao


marcbachmann


MondoGao


snyk-bot


Solais


thonatos


atian25


tommytroylin


wssgcg1213


yibn2008


fossabot


hugohua


hyj1991


mansonchor


givingwu


Abreto

This project follows the git-contributor spec, auto updated at Sat Mar 25 2023 22:23:53 GMT+0800.

Current Tags

  • 7.7.0                                ...           beta (2 years ago)
  • 7.12.0                                ...           latest (a year ago)
  • 1.16.0                                ...           latest-1 (6 years ago)
  • 2.31.0                                ...           latest-2 (6 years ago)
  • 3.28.1                                ...           latest-3 (3 years ago)
  • 4.11.0                                ...           latest-4 (4 years ago)
  • 5.8.1                                ...           latest-5 (3 years ago)
  • 6.8.0                                ...           latest-6 (a year ago)

268 Versions

  • 7.12.0                                ...           a year ago
  • 6.8.0                                ...           a year ago
  • 7.11.1                                ...           a year ago
  • 6.7.1                                ...           a year ago
  • 6.7.0                                ...           a year ago
  • 7.11.0                                ...           a year ago
  • 7.10.0                                ...           a year ago
  • 7.9.0                                ...           2 years ago
  • 7.8.0                                ...           2 years ago
  • 7.7.0                                ...           2 years ago
  • 7.6.1                                ...           2 years ago
  • 7.6.0                                ...           2 years ago
  • 7.5.2                                ...           2 years ago
  • 7.5.1                                ...           2 years ago
  • 7.5.0                                ...           2 years ago
  • 7.4.2                                ...           2 years ago
  • 7.4.1                                ...           2 years ago
  • 7.4.0                                ...           2 years ago
  • 7.3.1                                ...           2 years ago
  • 7.3.0                                ...           2 years ago
  • 7.2.2                                ...           2 years ago
  • 7.2.1                                ...           2 years ago
  • 7.2.0                                ...           2 years ago
  • 7.1.0                                ...           2 years ago
  • 7.0.0                                ...           2 years ago
  • 7.0.0-beta.2                                ...           2 years ago
  • 7.0.0-beta.1                                ...           2 years ago
  • 6.7.0-beta.1                                ...           2 years ago
  • 6.7.0-beta.0                                ...           2 years ago
  • 6.6.2                                ...           2 years ago
  • 6.6.1                                ...           2 years ago
  • 6.6.0                                ...           2 years ago
  • 6.5.2                                ...           2 years ago
  • 6.5.1                                ...           2 years ago
  • 6.5.0                                ...           2 years ago
  • 6.4.0                                ...           3 years ago
  • 6.3.0                                ...           3 years ago
  • 6.2.1                                ...           3 years ago
  • 6.2.0                                ...           3 years ago
  • 5.8.1                                ...           3 years ago
  • 5.8.0                                ...           3 years ago
  • 6.1.0                                ...           3 years ago
  • 6.0.0                                ...           3 years ago
  • 5.7.3                                ...           3 years ago
  • 5.7.2                                ...           3 years ago
  • 5.7.1                                ...           3 years ago
  • 5.7.0                                ...           3 years ago
  • 5.6.1                                ...           3 years ago
  • 5.6.0                                ...           3 years ago
  • 5.5.0                                ...           3 years ago
  • 5.4.1                                ...           3 years ago
  • 5.4.0                                ...           3 years ago
  • 5.3.1                                ...           3 years ago
  • 5.3.0                                ...           3 years ago
  • 3.28.1                                ...           3 years ago
  • 5.2.2                                ...           3 years ago
  • 5.2.1                                ...           3 years ago
  • 5.2.0                                ...           3 years ago
  • 5.1.2                                ...           3 years ago
  • 5.1.1                                ...           3 years ago
  • 5.1.0                                ...           3 years ago
  • 5.0.2                                ...           3 years ago
  • 5.0.1                                ...           3 years ago
  • 5.0.0                                ...           3 years ago
  • 4.11.0                                ...           4 years ago
  • 3.28.0                                ...           4 years ago
  • 4.10.0                                ...           4 years ago
  • 4.9.1                                ...           4 years ago
  • 4.9.0                                ...           4 years ago
  • 4.8.0                                ...           5 years ago
  • 3.27.0                                ...           5 years ago
  • 4.7.0                                ...           5 years ago
  • 3.26.0                                ...           5 years ago
  • 4.6.0                                ...           5 years ago
  • 3.25.2                                ...           5 years ago
  • 4.5.2                                ...           5 years ago
  • 3.25.1                                ...           5 years ago
  • 4.5.1                                ...           5 years ago
  • 4.5.1-beta.1                                ...           5 years ago
  • 4.5.0                                ...           5 years ago
  • 3.25.0                                ...           5 years ago
  • 4.4.0                                ...           5 years ago
  • 3.24.0                                ...           5 years ago
  • 4.3.0                                ...           5 years ago
  • 3.23.0                                ...           5 years ago
  • 4.2.0                                ...           5 years ago
  • 3.22.1                                ...           6 years ago
  • 4.1.1                                ...           6 years ago
  • 1.16.0                                ...           6 years ago
  • 2.31.0                                ...           6 years ago
  • 3.22.0                                ...           6 years ago
  • 4.1.0                                ...           6 years ago
  • 4.0.0                                ...           6 years ago
  • 3.21.1                                ...           6 years ago
  • 3.21.0                                ...           6 years ago
  • 3.20.2                                ...           6 years ago
  • 3.20.1                                ...           6 years ago
  • 3.20.0                                ...           6 years ago
  • 3.19.1                                ...           6 years ago
  • 3.19.0                                ...           6 years ago
  • 3.18.0                                ...           6 years ago
  • 3.17.0                                ...           6 years ago
  • 3.16.1                                ...           6 years ago
  • 3.16.0                                ...           6 years ago
  • 3.15.0                                ...           6 years ago
  • 3.14.0                                ...           6 years ago
  • 3.13.0                                ...           6 years ago
  • 3.12.0                                ...           6 years ago
  • 3.11.0                                ...           6 years ago
  • 3.10.0                                ...           6 years ago
  • 3.9.2                                ...           6 years ago
  • 3.9.1                                ...           6 years ago
  • 3.9.0                                ...           6 years ago
  • 3.8.0                                ...           7 years ago
  • 3.7.0                                ...           7 years ago
  • 3.6.2                                ...           7 years ago
  • 3.6.1                                ...           7 years ago
  • 3.6.0                                ...           7 years ago
  • 3.5.0                                ...           7 years ago
  • 3.4.0                                ...           7 years ago
  • 3.3.0                                ...           7 years ago
  • 3.2.1                                ...           7 years ago
  • 3.2.0                                ...           7 years ago
  • 3.1.4                                ...           7 years ago
  • 3.1.3                                ...           7 years ago
  • 3.1.2                                ...           7 years ago
  • 3.1.1                                ...           7 years ago
  • 3.1.0                                ...           7 years ago
  • 3.0.1                                ...           8 years ago
  • 2.30.2                                ...           8 years ago
  • 3.0.0                                ...           8 years ago
  • 2.30.1                                ...           8 years ago
  • 3.0.0-beta.4                                ...           8 years ago
  • 2.30.0                                ...           8 years ago
  • 2.29.2                                ...           8 years ago
  • 3.0.0-beta.3                                ...           8 years ago
  • 3.0.0-beta.2                                ...           8 years ago
  • 3.0.0-beta.1                                ...           8 years ago
  • 2.29.1                                ...           8 years ago
  • 2.29.0                                ...           8 years ago
  • 2.28.0                                ...           8 years ago
  • 2.27.1                                ...           8 years ago
  • 2.27.0                                ...           8 years ago
  • 2.26.4                                ...           8 years ago
  • 2.26.3                                ...           8 years ago
  • 2.26.2                                ...           8 years ago
  • 2.26.1                                ...           8 years ago
  • 2.26.0                                ...           8 years ago
  • 2.25.0                                ...           8 years ago
  • 2.24.1                                ...           8 years ago
  • 2.24.0                                ...           8 years ago
  • 2.23.0                                ...           8 years ago
  • 2.22.1                                ...           8 years ago
  • 2.22.0                                ...           8 years ago
  • 2.21.0                                ...           8 years ago
  • 2.20.0                                ...           8 years ago
  • 2.19.2                                ...           8 years ago
  • 2.19.1                                ...           8 years ago
  • 2.19.0                                ...           8 years ago
  • 2.18.2                                ...           8 years ago
  • 2.18.1                                ...           8 years ago
  • 2.18.0                                ...           8 years ago
  • 2.17.0                                ...           8 years ago
  • 2.16.1                                ...           8 years ago
  • 2.16.0                                ...           8 years ago
  • 2.15.0                                ...           8 years ago
  • 2.14.0                                ...           8 years ago
  • 2.13.3                                ...           8 years ago
  • 2.13.2                                ...           8 years ago
  • 2.13.1                                ...           8 years ago
  • 2.13.0                                ...           8 years ago
  • 2.12.2                                ...           8 years ago
  • 2.12.1                                ...           8 years ago
  • 2.12.0                                ...           8 years ago
  • 2.11.2                                ...           8 years ago
  • 2.11.1                                ...           8 years ago
  • 2.11.0                                ...           8 years ago
  • 2.10.0                                ...           8 years ago
  • 2.9.5                                ...           8 years ago
  • 2.9.4                                ...           8 years ago
  • 2.9.3                                ...           8 years ago
  • 2.9.2                                ...           8 years ago
  • 2.9.1                                ...           8 years ago
  • 2.9.0                                ...           8 years ago
  • 2.8.0                                ...           8 years ago
  • 2.7.0                                ...           8 years ago
  • 2.6.0                                ...           8 years ago
  • 2.5.0                                ...           8 years ago
  • 2.4.1                                ...           8 years ago
  • 2.4.0                                ...           8 years ago
  • 2.3.1                                ...           8 years ago
  • 2.3.0                                ...           8 years ago
  • 2.2.4                                ...           8 years ago
  • 2.2.3                                ...           8 years ago
  • 2.2.2                                ...           8 years ago
  • 2.2.1                                ...           8 years ago
  • 2.2.0                                ...           8 years ago
  • 2.1.1                                ...           8 years ago
  • 1.15.0                                ...           8 years ago
  • 2.1.0                                ...           8 years ago
  • 2.0.2                                ...           8 years ago
  • 2.0.1                                ...           8 years ago
  • 2.0.0                                ...           8 years ago
  • 2.0.0-beta.4                                ...           8 years ago
  • 1.14.2                                ...           8 years ago
  • 1.14.1                                ...           8 years ago
  • 2.0.0-beta.3                                ...           8 years ago
  • 2.0.0-beta.2                                ...           8 years ago
  • 2.0.0-beta.1                                ...           8 years ago
  • 1.14.0                                ...           8 years ago
  • 1.13.0                                ...           8 years ago
  • 1.12.1                                ...           8 years ago
  • 1.12.0                                ...           8 years ago
  • 1.11.1                                ...           8 years ago
  • 1.11.0                                ...           9 years ago
  • 1.10.1                                ...           9 years ago
  • 1.10.0                                ...           9 years ago
  • 1.9.0                                ...           9 years ago
  • 1.8.3                                ...           9 years ago
  • 1.8.2                                ...           9 years ago
  • 1.8.1                                ...           9 years ago
  • 1.8.0                                ...           9 years ago
  • 1.7.0                                ...           9 years ago
  • 1.6.5                                ...           9 years ago
  • 1.6.4                                ...           9 years ago
  • 1.6.3                                ...           9 years ago
  • 1.6.2                                ...           9 years ago
  • 1.6.1                                ...           9 years ago
  • 1.6.0                                ...           9 years ago
  • 1.5.3                                ...           9 years ago
  • 1.5.2                                ...           9 years ago
  • 1.5.1                                ...           9 years ago
  • 1.5.0                                ...           9 years ago
  • 1.4.2                                ...           9 years ago
  • 1.4.1                                ...           9 years ago
  • 1.4.0                                ...           9 years ago
  • 1.3.2                                ...           9 years ago
  • 1.3.1                                ...           9 years ago
  • 1.3.0                                ...           9 years ago
  • 1.2.5                                ...           9 years ago
  • 1.2.4                                ...           9 years ago
  • 1.2.3                                ...           9 years ago
  • 1.2.2                                ...           9 years ago
  • 1.2.1                                ...           9 years ago
  • 1.2.0                                ...           9 years ago
  • 1.1.1                                ...           9 years ago
  • 1.1.0                                ...           9 years ago
  • 1.0.8                                ...           9 years ago
  • 1.0.7                                ...           9 years ago
  • 1.0.6                                ...           9 years ago
  • 1.0.5                                ...           9 years ago
  • 1.0.4                                ...           9 years ago
  • 1.0.3                                ...           9 years ago
  • 1.0.2                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
  • 0.7.0                                ...           9 years ago
  • 0.6.0                                ...           9 years ago
  • 0.5.1                                ...           9 years ago
  • 0.5.0                                ...           9 years ago
  • 0.4.0                                ...           9 years ago
  • 0.3.0                                ...           9 years ago
  • 0.2.0                                ...           9 years ago
  • 0.1.0                                ...           9 years ago
  • 0.0.4                                ...           9 years ago
  • 0.0.3                                ...           9 years ago
  • 0.0.2                                ...           9 years ago
  • 0.0.1                                ...           9 years ago
Maintainers (2)
Downloads
Total 3
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (28)

© 2010 - cnpmjs.org x YWFE | Home | YWFE