pmex
v2.0.9
Published
Run dynamic NPM or YARN or PNPM
Downloads
177
Readme
Package Manager Execute
Dynamically selects NPM or YARN or PNPM or BUN to execute commands.
pmex [...command]
CLI
Auto Selection
Runs npm install
or yarn install
or pnpm install
or bun install
based on most recent LOCKFILE.
pmex install
Defined Commands
add
Add packages to the project.
pmex add typescript
# npm install typescript
# yarn add typescript
# pnpm add typescript
# bun add typescript
del
Remove packages from project.
Aliases: remove
, uninstall
.
pmex del typescript
# npm uninstall typescript
# yarn remove typescript
# pnpm remove typescript
# bun remove typescript
x
Aliases: dlx
.
Auto-install (no save) and run packages from NPM.
pmex x cowsay "Hello World!"
# npx cowsay "Hello World!"
# yarn dlx cowsay "Hello World!"
# pnpm dlx cowsay "Hello World!"
# bunx cowsay "Hello World!"
cc
Aliases: cache-clean
, cache-clear
.
Clear the package manager cache.
pmex cc
# npm cache clean --force
# yarn cache clean --all
# pnpm store prune
# bun pm cache rm
Scripting
This example runs npm install
or yarn install
or pnpm install
or bun install
based on what you used in the terminal: yarn start
or npm start
or pnpm start
or bun start
.
{
"scripts": {
"prestart": "pmex install",
"start": "node server.js"
}
}
Runtime
This example runs commands based on what you used to run the file.
import pmex from 'pmex';
// Different command based on package manager
pmex({
npm: 'cache clean --force',
yarn: 'cache clean --all',
pnpm: 'store prune',
bun: 'pm cache rm -g'
})
// Fallback to default
pmex({
bun: 'bunx cowsay "Hello World!"',
default: 'npx cowsay "Hello World!"'
})
pmex('test')
pmex('tsc --noEmit')
pmex('build')
Override
You can force the use of a package manager. This example runs npm install
for all package managers and then runs tsc
with automatic detection of the package manager.
import pmex from 'pmex';
pmex('npm install -g tsc')
pmex('tsc --noEmit')