Package managers
One command, one tab per package manager, remembered across pages.
One command shown for every package manager the site offers, with the reader's choice remembered for the whole site.
Usage
Write the command without the manager — add -D pkg, run build,
dlx create-nuxt. Each manager's own spelling is substituted.
pnpm add -D @kirchdev/duxtVerbs
| Written | pnpm | npm | yarn | bun |
|---|---|---|---|---|
add | add | install | add | add |
install | install | install | install | install |
remove | remove | uninstall | remove | remove |
run | run | run | run | run |
exec | exec | exec | exec | exec |
create | create | create | create | create |
dlx | pnpm dlx | npx | yarn dlx | bunx |
update | update | update | up | update |
outdated | outdated | outdated | — | outdated |
audit | audit | audit | npm audit | audit |
link | link | link | link | link |
why | why | why | why | why |
patch | patch | — | patch | patch |
yarn means Berry (≥ 2). Berry has no outdated and no global install, and
npm has no patch in any spelling — a dash above means that manager gets no
tab for that command rather than a near-equivalent doing a different job. The
build warns which page asked.
A -g or --global anywhere in the command is a global install, which drops the
yarn tab for the same reason.
i, rm, un, uninstall, up and upgrade are accepted as written and
folded onto the row that holds them. A verb not in the table is printed as
written for every manager, and the build says so — the table is always behind
some manager's newest subcommand, and refusing an unknown word would be worse
than showing it.
API
Props
| Prop | Type | Default | Notes |
|---|---|---|---|
command | string | required | Without the manager — add -D pkg |
managers | DuxtPackageManager[] | duxt.packageManagers | Overrides the site's list for one block |
Notes
The choice is a cookie, not browser storage, and deliberately: storage is read
after hydration, so the block would render one manager and then swap to another
in front of the reader. It is first-party, identifies nobody and carries a value
the reader picked — see
usePackageManager().
A block may list fewer managers than the reader's choice covers; it falls back to its own first tab rather than showing nothing.