Skip to content

Running javascript package manager commands

Ever run yarn in a repository that uses pnpm? Stop thinking about which package manager to run commands with.

Use @antfu/ni instead.

Installation#

Terminal window
pnpm add -g @antfu/ni

OR using mise.

Terminal window
asdf plugin add ni https://github.com/CanRau/asdf-ni.git
asdf install ni latest
asdf global ni latest

Usage#

Running shell commands within the context of a project. Useful when I want to run a cli that is installed within a project but not exposed through the package.json scripts like cdk or biome.

Terminal window
na exec biome check --fix --unsafe
# equivalent to 'pnpm exec biome check --fix --unsafe'

na is the shorthand for running the current package manager e.g. yarn / npm / pnpm.