Skip to content

Get user package manager, version, and translate npm commands to user package manager.

License

Notifications You must be signed in to change notification settings

brunocroh/local-package-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Local Package Manager

Get package manager of user, and translate commands to him

npm version local-package-manager is released under the MIT license. PRs welcome! Contact me at @brunocroh

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 npm */
//=> try running: npx some-lib --example

Maintainers

About

Get user package manager, version, and translate npm commands to user package manager.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published