Tool ni
is a utility that removes the need to recognize a type of package manager in JS projects (npm, yarn, pnpm, bun). It provides a unified interface and uses appropriate commands instead (calls yarn
in yarn projects, npm
in npm projects, etc.).
Let's assume getting a project with an unknown manager (at least for the first 5 seconds) or just a situation when we work with multiple projects having different managers. It may become a little bit annoying to pay attention to which manager we need.
The ni
is a CLI utility that recognizes a project package manager according to its lock file (yarn.lock
, package-lock.json
, etc.) and uses appropriate commands. At least basic ones that could be unified.
Installation
npm i -g @antfu/ni
Also, it is better to create a config ~/.nirc
with default values.
defaultAgent=npm
globalAgent=npm
Usage
Examples below are based on the yarn
commands.
ni # yarn install
ni X # yarn add X
ni -D X # yarn add -D X
nr dev # yarn run dev
na # yarn
A full list is defined at README.md of the library.
It is nothing too special, but it removes a tiny annoying part during app development.