[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-10352":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":23,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":32,"readmeContent":33,"aiSummary":34,"trendingCount":16,"starSnapshotCount":16,"syncStatus":35,"lastSyncTime":36,"discoverSource":37},10352,"ni","antfu-collective\u002Fni","antfu-collective","💡 Use the right package manager","",null,"TypeScript",8240,271,17,22,0,1,4,46,6,71.9,"MIT License",false,"main",true,[27,28,29,30,31],"cli","npm","package-manager","pnpm","yarn","2026-06-12 04:00:49","# ni\n\n~~*`npm i` in a yarn project, again? F\\*\\*k!*~~\n\n**ni** - use the right package manager\n\n\u003Cbr>\n\n\u003Cpre>\n\u003Ccode>\nnpm i -g \u003Cb>@antfu\u002Fni\u003C\u002Fb>\n\u003C\u002Fcode>\n\u003C\u002Fpre>\n\n\u003Ca href='https:\u002F\u002Fdocs.npmjs.com\u002Fcli\u002Fv6\u002Fcommands\u002Fnpm'>npm\u003C\u002Fa> · \u003Ca href='https:\u002F\u002Fyarnpkg.com'>yarn\u003C\u002Fa> · \u003Ca href='https:\u002F\u002Fpnpm.io\u002F'>pnpm\u003C\u002Fa> · \u003Ca href='https:\u002F\u002Fbun.sh\u002F'>bun\u003C\u002Fa> · \u003Ca href='https:\u002F\u002Fdeno.land\u002F'>deno\u003C\u002Fa>\n\n\u003Cbr>\n\n### `ni` - install\n\n```bash\nni\n\n# npm install\n# yarn install\n# pnpm install\n# bun install\n# deno install\n```\n\n```bash\nni vite\n\n# npm i vite\n# yarn add vite\n# pnpm add vite\n# bun add vite\n# deno add vite\n```\n\n```bash\nni @types\u002Fnode -D\n\n# npm i @types\u002Fnode -D\n# yarn add @types\u002Fnode -D\n# pnpm add -D @types\u002Fnode\n# bun add -d @types\u002Fnode\n# deno add -D @types\u002Fnode\n```\n\n```bash\nni -P\n\n# npm i --omit=dev\n# yarn install --production\n# pnpm i --production\n# bun install --production\n# (deno not supported)\n```\n\n```bash\nni --frozen\n\n# npm ci\n# yarn install --frozen-lockfile (Yarn 1)\n# yarn install --immutable (Yarn Berry)\n# pnpm install --frozen-lockfile\n# bun install --frozen-lockfile\n# deno install --frozen\n```\n\n```bash\nni -g eslint\n\n# npm i -g eslint\n# yarn global add eslint (Yarn 1)\n# pnpm add -g eslint\n# bun add -g eslint\n# deno install eslint\n\n# this uses default agent, regardless your current working directory\n```\n\n```bash\nni -i\n\n# interactively select the dependency to install\n# search for packages by name\n```\n\n\u003Cdetails>\n\u003Csummary>catalogs support\u003C\u002Fsummary>\n\n> Since v29.0.0\n\nWhen working in a pnpm workspace with [catalogs](https:\u002F\u002Fpnpm.io\u002Fcatalogs) configured in `pnpm-workspace.yaml`, `ni` automatically enters **catalog mode**. Instead of adding packages with pinned versions, it writes `catalog:` references into `package.json` and updates the workspace catalog.\n\n```bash\n# Given pnpm-workspace.yaml with:\n#   catalogs:\n#     prod:\n#       react: ^18.3.0\n\nni react\n# → detects react in \"prod\" catalog\n# → writes \"react\": \"catalog:prod\" to package.json\n# → runs pnpm install\n\nni lodash\n# → lodash not in any catalog\n# → prompts to select a catalog (or skip)\n# → fetches latest version, updates pnpm-workspace.yaml\n# → writes \"lodash\": \"catalog:prod\" to package.json\n# → runs pnpm install\n```\n\nWhen only a default catalog (`catalog:` top-level) is used, new packages are added directly without prompting. When only named catalogs exist, the default catalog is never offered.\n\nFlags like `-D` are respected — the catalog ref is written to the correct `package.json` section:\n\n```bash\nni typescript -D\n# → writes \"typescript\": \"catalog:dev\" to devDependencies\n```\n\nUse `-w` \u002F `--workspace` to target the workspace root `package.json`:\n\n```bash\nni react -w\n# → writes catalog ref to workspace root package.json\n```\n\nTo disable catalog mode, set `catalog=false` in `~\u002F.nirc` or `NI_CATALOG=false` environment variable.\n\n\u003C\u002Fdetails>\n\n\u003Cbr>\n\n### `nr` - run\n\n```bash\nnr dev --port=3000\n\n# npm run dev -- --port=3000\n# yarn run dev --port=3000\n# pnpm run dev --port=3000\n# bun run dev --port=3000\n# deno task dev --port=3000\n```\n\n```bash\nnr\n\n# interactively select the script to run\n# supports https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fnpm-scripts-info convention\n```\n\n```bash\nnr -\n\n# rerun the last command\n```\n\n```bash\nnr -p\nnr -p dev\n\n# interactively select the package and script to run\n```\n\n\u003Cdetails>\n\u003Csummary>shell completion scripts\u003C\u002Fsummary>\n\n```bash\n# Add completion script for bash\nnr --completion-bash >> ~\u002F.bashrc\n\n# Add completion script for zsh\n# For zim:fw\nmkdir -p ~\u002F.zim\u002Fcustom\u002Fni-completions\nnr --completion-zsh > ~\u002F.zim\u002Fcustom\u002Fni-completions\u002F_ni\necho \"zmodule $HOME\u002F.zim\u002Fcustom\u002Fni-completions --fpath .\" >> ~\u002F.zimrc\nzimfw install\n\n# Add completion script for fish\nmkdir -p ~\u002F.config\u002Ffish\u002Fcompletions\nnr --completion-fish > ~\u002F.config\u002Ffish\u002Fcompletions\u002Fnr.fish\n```\n\n\u003C\u002Fdetails>\n\n\u003Cbr>\n\n### `nlx` - download & execute\n\n```bash\nnlx vitest\n\n# npx vitest\n# yarn dlx vitest\n# pnpm dlx vitest\n# bunx vitest\n# deno run npm:vitest\n```\n\n\u003Cbr>\n\n### `nup` - upgrade\n\n```bash\nnup\n\n# npm upgrade\n# yarn upgrade (Yarn 1)\n# yarn up (Yarn Berry)\n# pnpm update\n# bun update\n# deno upgrade\n```\n\n```bash\nnup -i\n\n# (not available for npm)\n# yarn upgrade-interactive (Yarn 1)\n# yarn up -i (Yarn Berry)\n# pnpm update -i\n# bun update -i\n# deno outdated -u -i\n```\n\n\u003Cbr>\n\n### `nun` - uninstall\n\n```bash\nnun webpack\n\n# npm uninstall webpack\n# yarn remove webpack\n# pnpm remove webpack\n# bun remove webpack\n# deno remove webpack\n```\n\n```bash\nnun\n\n# interactively multi-select\n# the dependencies to remove\n```\n\n```bash\nnun -g silent\n\n# npm uninstall -g silent\n# yarn global remove silent\n# pnpm remove -g silent\n# bun remove -g silent\n# deno uninstall -g silent\n```\n\n\u003Cbr>\n\n### `nci` - clean install\n\n```bash\nnci\n\n# npm ci\n# yarn install --frozen-lockfile\n# pnpm install --frozen-lockfile\n# bun install --frozen-lockfile\n# deno cache --reload\n```\n\n\u003Cbr>\n\n### `nd` - dedupe dependencies\n\n```bash\nnd\n\n# npm dedupe\n# yarn dedupe\n# pnpm dedupe\n```\n\n\u003Cbr>\n\n### `na` - agent alias\n\n```bash\nna\n\n# npm\n# yarn\n# pnpm\n# bun\n# deno\n```\n\n```bash\nna run foo\n\n# npm run foo\n# yarn run foo\n# pnpm run foo\n# bun run foo\n# deno task foo\n```\n\n\u003Cbr>\n\n### Global Flags\n\n```bash\n# ?               | Print the command execution depends on the agent\nni vite ?\n\n# -C              | Change directory before running the command\nni -C packages\u002Ffoo vite\nnr -C playground dev\n\n# -v, --version   | Show version number\nni -v\n\n# -h, --help      | Show help\nni -h\n```\n\n\u003Cbr>\n\n### Config\n\n```ini\n; ~\u002F.nirc\n\n; fallback when no lock found\ndefaultAgent=npm # default \"prompt\"\n\n; for global installs\nglobalAgent=npm\n\n; use node --run instead of package manager run command (requires Node.js 22+)\nrunAgent=node\n\n; prefix commands with sfw\nuseSfw=true\n\n; use catalog mode when catalogs are detected (default true)\ncatalog=true\n```\n\n```bash\n# ~\u002F.bashrc\n\n# custom configuration file path\nexport NI_CONFIG_FILE=\"$HOME\u002F.config\u002Fni\u002Fnirc\"\n\n# environment variables have higher priority than config file if presented\nexport NI_DEFAULT_AGENT=\"npm\" # default \"prompt\"\nexport NI_GLOBAL_AGENT=\"npm\"\nexport NI_USE_SFW=\"true\"\nexport NI_CATALOG=\"false\" # disable catalog mode\n```\n\n```ps\n# for Windows\n\n# custom configuration file path in PowerShell accessible within the `$profile` path\n$Env:NI_CONFIG_FILE = 'C:\\to\\your\\config\\location'\n```\n\n\u003Cbr>\n\n### Automatic installation\n\nYou can set `NI_AUTO_INSTALL=true` to enable automatic installation.\n\nIf the corresponding package manager (**npm**, **yarn**, **pnpm**, **bun**, or **deno**) is not installed, it will install it globally before running the command.\n\n### Integrations\n\n#### Homebrew\n\nYou can install ni with [Homebrew](https:\u002F\u002Fbrew.sh\u002F):\n\n```bash\nbrew install ni\n```\n\n#### asdf\n\nYou can also install ni via the [3rd-party asdf-plugin](https:\u002F\u002Fgithub.com\u002FCanRau\u002Fasdf-ni.git) maintained by [CanRau](https:\u002F\u002Fgithub.com\u002FCanRau)\n\n```bash\n# first add the plugin\nasdf plugin add ni https:\u002F\u002Fgithub.com\u002FCanRau\u002Fasdf-ni.git\n\n# then install the latest version\nasdf install ni latest\n\n# and make it globally available\nasdf global ni latest\n```\n\n### How?\n\n**ni** assumes that you work with lock-files (and you should).\n\nBefore `ni` runs the command, it detects your `yarn.lock` \u002F `pnpm-lock.yaml` \u002F `package-lock.json` \u002F `bun.lock` \u002F `bun.lockb` \u002F `deno.json` \u002F `deno.jsonc` to know the current package manager (or `packageManager` field in your packages.json if specified) using the [package-manager-detector](https:\u002F\u002Fgithub.com\u002Fantfu-collective\u002Fpackage-manager-detector) package and then runs the corresponding [package-manager-detector command](https:\u002F\u002Fgithub.com\u002Fantfu-collective\u002Fpackage-manager-detector\u002Fblob\u002Fmain\u002Fsrc\u002Fcommands.ts).\n\n### Trouble shooting\n\n#### Conflicts with PowerShell\n\nPowerShell comes with a built-in alias `ni` for the `New-Item` cmdlet. To remove the alias in your current PowerShell session in favor of this package, use the following command:\n\n```PowerShell\n'Remove-Item Alias:ni -Force -ErrorAction Ignore'\n```\n\nIf you want to persist the changes, you can add them to your PowerShell profile. The profile path is accessible within the `$profile` variable. The ps1 profile file can normally be found at\n\n- PowerShell 5 (Windows PowerShell): `C:\\Users\\USERNAME\\Documents\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1`\n- PowerShell 7: `C:\\Users\\USERNAME\\Documents\\PowerShell\\Microsoft.PowerShell_profile.ps1`\n- VSCode: `C:\\Users\\USERNAME\\Documents\\PowerShell\\Microsoft.VSCode_profile.ps1`\n\nYou can use the following script to remove the alias at shell start by adding the above command to your profile:\n\n```PowerShell\nif (-not (Test-Path $profile)) {\n  New-Item -ItemType File -Path (Split-Path $profile) -Force -Name (Split-Path $profile -Leaf)\n}\n\n$profileEntry = 'Remove-Item Alias:ni -Force -ErrorAction Ignore'\n$profileContent = Get-Content $profile\nif ($profileContent -notcontains $profileEntry) {\n  (\"`n\" + $profileEntry) | Out-File $profile -Append -Force -Encoding UTF8\n}\n```\n\n#### `nx`, `nix` and `nu` are no longer available\n\nWe renamed `nx`\u002F`nix` and `nu` to `nlx` and `nup` to avoid conflicts with the other existing tools - [nx](https:\u002F\u002Fnx.dev\u002F), [nix](https:\u002F\u002Fnixos.org\u002F) and [nushell](https:\u002F\u002Fwww.nushell.sh\u002F). You can always alias them back on your shell configuration file (`.zshrc`, `.bashrc`, etc).\n\n```bash\nalias nx=\"nlx\"\n# or\nalias nix=\"nlx\"\n# or\nalias nu=\"nup\"\n```\n","ni 是一个智能选择正确包管理器的 CLI 工具。它能够自动检测项目中使用的包管理器（如 npm、yarn、pnpm、bun 或 deno），并执行相应的命令，从而避免了在不同环境中手动切换工具的麻烦。核心功能包括依赖安装、全局包安装、交互式安装以及支持 pnpm 的 catalog 功能等。适用于需要频繁切换或同时使用多种包管理器的开发场景，尤其适合大型或多语言技术栈的项目团队。",2,"2026-06-11 03:27:56","top_topic"]