Detect which package manager that should be used
npm install --save pkg-man
$ tree
├── bar
│ ├── package.json
│ └── yarn.lock
├── baz
│ ├── package-lock.json
│ ├── package.json
│ └── yarn.lock
├── foo
│ ├── package-lock.json
│ └── package.json
└── package.json
const pkgMan = require('pkg-man');
pkgMan({ cwd: 'bar' });
//=> yarn
pkgMan({ cwd: 'baz' });
//=> npm
pkgMan({ cwd: 'foo' });
//=> npm
pkgMan();
//=> npm
pkgMan({ preferred: 'yarn' });
//=> yarn
pkgMan({ cwd: 'baz', preferred: 'yarn' });
//=> yarn
Type: Object
Type: string
Default: process.cwd()
Current working directory.
Type: string
Default: npm
Preferred package manager if no lockfile or multiple lockfiles found.
- pkg-man-cli - CLI for this module
- has-lockfile - Detect lockfiles in the working directory
MIT © Lufty Wiranda