local-package-manager
v1.0.5
Published
Get package manager of user, and translate commands to him
Downloads
3
Readme
Install
npm install -D local-package-manager
Usage
Get the user package manager
works with yarn, npm, and pnpm
import { getPackageManager } from 'local-package-manager';
const packageManager = await getPackageManager();
console.log(packageManager);
//=> {name: 'npm', version: '8.11.0'}
Translate a command to the package manager of user
import { getCommand } from 'local-package-manager';
const npxCommand = await getCommand('npx');
console.log(`try running: ${npxCommand} some-lib --example
`);
/* if user using pnpm */
//=> try running: pnpm exec some-lib --example
/* if user using yarn */
//=> try running: yarn some-lib --example
/* if user using pnpm */
//=> try running: npx some-lib --example