npminstall
![npm download](https://img.shields.io/npm/dm/npminstall.svg?style=flat-square)
Let npm install
fast and easy.
Installation
$ npm install npminstall --save
Quick start
const co = require('co');
const npminstall = require('npminstall');
co(function*() {
yield npminstall({
root: process.cwd(),
});
}).catch(function(err) {
console.error(err.stack);
});
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).
node_modules
directory
Two rules:
- The latest version of modules will link at
options.storeDir
's node_modules
. - 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@0.7.0
- pnpm@0.18.0
- npm@2.14.12
cli | real | user | sys |
---|
npminstall | 0m13.808s | 0m9.679s | 0m4.854s |
npminstall with cache | 0m11.712s | 0m8.769s | 0m4.377s |
npminstall --no-cache | 0m11.778s | 0m9.179s | 0m4.358s |
pnpm | 0m17.991s | 0m13.847s | 0m5.205s |
npm | 0m34.436s | 0m30.282s | 0m9.759s |
npm with cache | 0m36.533s | 0m24.625s | 0m7.562s |
License
MIT