๐Ÿ“ฆ leog / package-manager-alias-cli

One command to use any* package manager

โ˜… 0 stars โ‘‚ 0 forks ๐Ÿ‘ 0 watching โš–๏ธ MIT License
๐Ÿ“ฅ Clone https://github.com/leog/package-manager-alias-cli.git
HTTPS git clone https://github.com/leog/package-manager-alias-cli.git
SSH git clone git@github.com:leog/package-manager-alias-cli.git
CLI gh repo clone leog/package-manager-alias-cli
Leo Giovanetti Leo Giovanetti chore(release): 1.1.0 ae2469a 1 days ago ๐Ÿ“ History
๐Ÿ“‚ main View all commits โ†’
๐Ÿ“ .github
๐Ÿ“„ .eslintrc.js
๐Ÿ“„ .gitignore
๐Ÿ“„ .prettierrc
๐Ÿ“„ .versionrc
๐Ÿ“„ CHANGELOG.md
๐Ÿ“„ CONTRIBUTING.md
๐Ÿ“„ LICENSE
๐Ÿ“„ package-lock.json
๐Ÿ“„ package.json
๐Ÿ“„ pm.js
๐Ÿ“„ pm.test.js
๐Ÿ“„ README.md
๐Ÿ“„ README.md

package-manager-alias-cli

npm version License: MIT Node.js CI

One command to use any\* package manager. A universal CLI that auto-detects and uses npm, yarn, pnpm, or bun.

Install

npm install -g package-manager-alias-cli

Or with other package managers:

yarn global add package-manager-alias-cli
pnpm add -g package-manager-alias-cli
bun add -g package-manager-alias-cli

Usage

Go to any Node.js project and use pm instead of your package manager:

# Instead of npm install / yarn install / pnpm install / bun install
pm install

# Instead of npm add lodash / yarn add lodash / pnpm add lodash / bun add lodash
pm add lodash

# Run scripts
pm run build
pm run test

# Any command works!
pm outdated
pm update
pm remove lodash

Options

-v, --version   Show version number
-h, --help      Show help message
--verbose       Show which package manager is being used

Examples

# Check the version
pm --version

# See help
pm --help

# See which package manager is detected
pm --verbose install
# Output: Detected package manager: yarn
#         yarn install v1.22.19
#         ...

How Detection Works

The tool detects your package manager in this priority order:

  • Lockfile detection (highest priority):
  • yarn.lock โ†’ yarn
  • package-lock.json โ†’ npm
  • pnpm-lock.yaml โ†’ pnpm
  • bun.lockb โ†’ bun
  • Fallback (if no lockfile found):
  • Checks if yarn, pnpm, or bun command exists
  • Falls back to npm if none are found
  • Caching: Results are cached for performance

Troubleshooting

"Could not detect package manager"

This error occurs when you're not in a Node.js project directory. Make sure:

  • You have a package.json file in the current directory
  • Or you have a lockfile (package-lock.json, yarn.lock, pnpm-lock.yaml, or bun.lockb)

Wrong package manager detected

The tool prioritizes lockfiles. If you want to switch package managers:

  • Delete the old lockfile
  • Run pm install to generate a new lockfile with your preferred package manager

Command not found: pm

Make sure the package is installed globally:

npm install -g package-manager-alias-cli

Then verify it's in your PATH:

which pm

Why Use This?

  • Consistency: Use one command across all projects
  • Simplicity: No need to remember which package manager each project uses
  • Speed: Automatically uses the fastest available package manager
  • Team-friendly: Works regardless of individual developer preferences

Contributing

Contributions are welcome! Please read our Contributing Guide for details.

Changelog

See CHANGELOG.md for a list of changes.

License

MIT - Leo Giovanetti