New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

npminstall

Package Overview
Dependencies
Maintainers
2
Versions
268
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npminstall

Let npm install fast and easy

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.9K
decreased by-67.85%
Maintainers
2
Weekly downloads
 
Created
Source

npminstall

NPM version build status appveyor build status Test coverage David deps npm download

Let npm install fast and easy.

Use as Cli

Install

$ npm install npminstall --g

Usage

Usage:

  npminstall
  npminstall <pkg>
  npminstall <pkg>@<tag>
  npminstall <pkg>@<version>
  npminstall <pkg>@<version range>
  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 chinses npm registry and other binary's mirrors

Use as Lib

Install

$ npm install npminstall --save

Usage

const co = require('co');
const npminstall = require('npminstall');

co(function*() {
  yield 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 + '.npminstall',
  });
}).catch(function(err) {
  console.error(err.stack);
});

Support Features

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

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": { "a": "1.0.0" } } (root)
  • a@1.0.0: { "dependencies": { "c": "2.0.0", "b": "1.0.0" } }
  • b@1.0.0: { "dependencies": { "c": "1.0.0" } }
  • c@1.0.0 & c@2.0.0: { "dependencies": { } }
app/
└── node_modules/
    ├── .npminstall/
    │   ├── debug/
    │   │   └── 2.2.0/
    │   │       └── debug/
    │   │           └──  node_modules/
    │   │               └── ms -> ../../../../ms/0.7.1/ms
    │   ├── ms/
    │   │   ├── 0.5.1/
    │   │   │   └── ms/
    │   │   └── 0.7.1/
    │   │       └── ms/
    │   └── node_modules/
    │       └── ms -> ../ms/0.7.1/ms
    ├── debug -> .npminstall/debug/2.2.0/debug
    └── ms -> .npminstall/ms/0.5.1/ms

debug@1.0.0 is root package, won't create link at app/node_modules/.npminstall/node_modules/debug@.

Benchmarks

  • npminstall@1.2.0
  • pnpm@0.18.0
  • npm@2.14.12
clirealusersys
npminstall0m10.908s0m8.733s0m4.282s
npminstall with cache0m8.815s0m7.492s0m3.644s
npminstall --no-cache0m10.279s0m8.255s0m3.932s
pnpm0m13.509s0m11.650s0m4.443s
npm0m28.171s0m26.085s0m8.219s
npm with cache0m20.939s0m19.415s0m6.302s

License

MIT

Keywords

FAQs

Package last updated on 02 Mar 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc