ni - use the right package manager
You can run npm/yarn/pnpm/bun with same command!
- Original: https://github.com/antfu/ni
zinit load azu/ni.zshantigen bundle azu/ni.zsh@main[plugins.ni]
github = "azu/ni.zsh"curl https://raw.githubusercontent.com/azu/ni.zsh/main/ni.zsh > ni.zsh
source ni.zshni.zsh requires compdef command.
If you got command not found: compdef error, you need to enable compinit in your .zshrc.
# .zshrc
# load compdef
autoload -Uz compinit && compinit
# load ni.zsh
source /path/to/ni.zsh- zsh
- require to enable
autoload -Uz compinit && compinit
- require to enable
- jq
- npm-check if you want to use
npm+ni upgrade-interactive
ni -- install current package.json
ni add <pkg> -- add package
ni remove <pkg> -- remove package
ni run <script> -- run scripts
ni test -- run test script
ni upgrade [<pkg>] -- upgrade packages
ni upgrade-interactive -- upgrade package interactively
ni exec <command> -- execute command
ni dlx <pkg> -- download package and execute command| ni | npm | yarn | yarn-berry | pnpm | bun | deno |
|---|---|---|---|---|---|---|
ni |
npm install |
yarn install |
yarn install |
pnpm install |
bun install |
deno install |
ni add <pkg> |
npm install |
yarn add |
yarn add |
pnpm add |
bun add |
deno add --npm |
ni remove <pkg> |
npm uninstall |
yarn remove |
yarn remove |
pnpm remove |
bun remove |
deno uninstall |
ni run <script> |
npm run |
yarn run |
yarn run |
pnpm run |
bun run |
deno run |
ni test |
npm run test |
yarn run test |
yarn run test |
pnpm run test |
bun run test |
deno run test |
ni upgrade |
npm upgrade |
yarn upgrade |
yarn up |
pnpm update |
bun update |
deno outdated --update |
ni upgrade-interactive |
npm-check^1 |
yarn up --interactive "*" |
yarn upgrade-interactive |
pnpm update -i |
○ | deno outdated --update --interactive |
ni exec <command> |
npm exec --no |
yarn <command> |
yarn exec |
pnpm exec |
bunx |
○ |
ni dlx <pkg> |
npx |
npx |
yarn dlx |
pnpm dlx |
bunx |
deno x |
- ^1: require npm-check globally.
Notes
- Installing devDependencies:
ni add --dev <pkg> - Additional arguments for
ni run:ni run dev --port 8080 - Update specific package:
ni upgrade <pkg>
ni <TAB>You can integrate Socket Firewall to detect supply chain attacks.
nizsh-socket-firewall_optimized.mp4
Socket Firewall provides proactive protection against malicious packages by scanning all package installations and executions in real-time.
Setup:
-
Install Socket Firewall globally:
npm i -g sfw
-
Enable Socket Firewall in ni.zsh:
export NI_USE_SOCKET_FIREWALL=1 -
(Optional) Specify custom sfw binary path:
export NI_SOCKET_FIREWALL_BIN=/path/to/sfwIf not set, uses
sfwcommand from PATH.
Protected commands:
When Socket Firewall is enabled, the following commands are automatically protected:
ni add/ni- Package installationni exec/ni dlx- Package execution (npx,bunx)
MIT © azu