{"id":16019566,"url":"https://github.com/fjc0k/tbify","last_synced_at":"2025-04-09T13:03:30.295Z","repository":{"id":47510006,"uuid":"259914175","full_name":"fjc0k/tbify","owner":"fjc0k","description":"使用淘宝镜像运行命令: tbify [nvm|npm|npx|yarn|pnpm|...]","archived":false,"fork":false,"pushed_at":"2024-01-15T12:31:13.000Z","size":250,"stargazers_count":210,"open_issues_count":1,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T02:46:42.135Z","etag":null,"topics":["cnpm","npm","package-manager","pnpm","taobao","taobao-mirror","taobao-registry","yarn"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/tbify","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fjc0k.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-29T12:04:41.000Z","updated_at":"2025-03-24T05:16:58.000Z","dependencies_parsed_at":"2024-01-15T14:17:36.680Z","dependency_job_id":"c23c400f-9081-4b4d-af64-9281fe951e2a","html_url":"https://github.com/fjc0k/tbify","commit_stats":{"total_commits":52,"total_committers":1,"mean_commits":52.0,"dds":0.0,"last_synced_commit":"a36445275f6034c2cba3a39e67c1f87560d545be"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjc0k%2Ftbify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjc0k%2Ftbify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjc0k%2Ftbify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjc0k%2Ftbify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fjc0k","download_url":"https://codeload.github.com/fjc0k/tbify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045230,"owners_count":21038553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cnpm","npm","package-manager","pnpm","taobao","taobao-mirror","taobao-registry","yarn"],"created_at":"2024-10-08T17:04:47.918Z","updated_at":"2025-04-09T13:03:30.267Z","avatar_url":"https://github.com/fjc0k.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tbify\n\n使用 [淘宝 NPM 镜像](https://developer.aliyun.com/mirror/NPM) 加速包管理工具安装依赖的速度。\n\n---\n\n\u003c!-- TOC depthFrom:2 --\u003e\n\n- [原理](#原理)\n- [安装](#安装)\n- [使用](#使用)\n- [手动同步 NPM 包到淘宝镜像](#手动同步-npm-包到淘宝镜像)\n- [鸣谢](#鸣谢)\n- [许可](#许可)\n\n\u003c!-- /TOC --\u003e\n\n## 原理\n\n基于环境变量对国内请求速度欠佳的资源地址进行了替换，具体分为两点：\n\n- 通过环境变量令包管理工具（`npm`、`npx`、`yarn`、`pnpm`、`pnpx`）使用淘宝源安装依赖；\n- 通过环境变量令诸如 `nvm`、`fnm`、`node-sass`、`Electron`、`Puppeteer`、`Cypress`、`Sharp`、`Prisma` 等工具或包使用淘宝镜像安装其自身所需资源。\n\n以上，本工具对包管理工具本身零侵入，同时，对环境变量的设置也是一次性的，并不会产生任何的副作用，请放心使用。\n\n## 安装\n\n```bash\n# npm\nnpm install tbify --global\n\n# yarn\nyarn global add tbify\n\n# pnpm\npnpm add --global tbify\n```\n\n## 使用\n\n对于常用的包管理命令，`tbify` 提供了使用淘宝 NPM 镜像的等价命令，除了发布包到 npm 时必须使用 `npm publish` 外，都可以使用等价命令进行相关操作：\n\n| 原命令 | 使用淘宝 NPM 镜像的命令                                                       | 示例                  |\n| ------ | ----------------------------------------------------------------------------- | --------------------- |\n| `nvm`  | `tnvm` / `tbify nvm`                                                          | `tnvm install 8.0.0`  |\n| `fnm`  | `tfnm` / `tbify fnm`                                                          | `tfnm install 20`     |\n| `npm`  | `tnpm` / `tbify npm`                                                          | `tnpm install react`  |\n| `npx`  | `tnpx` / `tbify npx`                                                          | `tnpx kill-port 3000` |\n| `yarn` | `tyn` / `tyarn` / `tbify yarn`                                                | `tyn add react`       |\n| `pnpm` | `tpm` (Windows 下该命令被系统占用，请使用后面的替代) / `tpnpm` / `tbify pnpm` | `tpm add react`       |\n| `pnpx` | `tpx` / `tpnpx` / `tbify pnpx`                                                | `tpx kill-port 3000`  |\n\n对于其他命令，在使用时加上 `tbify` 前缀即可，比如：\n\n```bash\ntbify printenv npm_config_registry\n# -\u003e https://registry.npmmirror.com\n```\n\n若想覆盖内部的环境变量值，可在使用 `tbify` 前设置：\n\n```bash\nnpm_config_registry=https://my.npm.mirror tbify printenv npm_config_registry\n# -\u003e https://my.npm.mirror\n```\n\n## 手动同步 NPM 包到淘宝镜像\n\n可以通过 `tsync` 或 `tbify sync` 命令手动同步一个或多个 NPM 包到淘宝镜像。\n\n```bash\n# 一个\ntsync vue\n\n# 多个\ntsync vue react\n```\n\n## 鸣谢\n\n正所谓前人栽树后人乘凉，感谢 [@fengmk2](https://github.com/fengmk2) 大佬及 [cnpm 团队](https://github.com/cnpm) 为提供一个优质国内镜像所作出的努力！👍\n\n同时本工具从 [@yiminghe](https://github.com/yiminghe) 大佬的 [tyarn](https://github.com/yiminghe/tyarn) 项目借鉴了很多思路，一并表示感谢！💐\n\n## 许可\n\nJay Fong (c) MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffjc0k%2Ftbify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffjc0k%2Ftbify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffjc0k%2Ftbify/lists"}