Last active
March 11, 2021 12:34
-
-
Save xiaoysh8/4d5fe76402e3f1578aaefdd13f609305 to your computer and use it in GitHub Desktop.
npm china mirror
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ npm install -g cnpm --registry=https://registry.npm.taobao.org | |
| 或者你直接通过添加 npm 参数 alias 一个新命令: | |
| alias cnpm="npm --registry=https://registry.npm.taobao.org \ | |
| --cache=$HOME/.npm/.cache/cnpm \ | |
| --disturl=https://npm.taobao.org/dist \ | |
| --userconfig=$HOME/.cnpmrc" | |
| # Or alias it in .bashrc or .zshrc | |
| $ echo '\n#alias for cnpm\nalias cnpm="npm --registry=https://registry.npm.taobao.org \ | |
| --cache=$HOME/.npm/.cache/cnpm \ | |
| --disturl=https://npm.taobao.org/dist \ | |
| --userconfig=$HOME/.cnpmrc"' >> ~/.zshrc && source ~/.zshrc | |
| 安装模块 | |
| 从 registry.npm.taobao.org 安装所有模块. 当安装的时候发现安装的模块还没有同步过来, 淘宝 NPM 会自动在后台进行同步, 并且会让你从官方 NPM registry.npmjs.org 进行安装. 下次你再安装这个模块的时候, 就会直接从 淘宝 NPM 安装了. | |
| $ cnpm install [name] | |
| 同步模块 | |
| 直接通过 sync 命令马上同步一个模块, 只有 cnpm 命令行才有此功能: | |
| $ cnpm sync connect | |
| 当然, 你可以直接通过 web 方式来同步: /sync/connect | |
| $ open https://npm.taobao.org/sync/connect | |
| 其它命令 | |
| 支持 npm 除了 publish 之外的所有命令, 如: | |
| $ cnpm info connect | |
| npm config set registry https://registry.npm.taobao.org --global | |
| npm config set disturl https://npm.taobao.org/dist --global | |
| yarn config set registry https://registry.npm.taobao.org --global | |
| yarn config set disturl https://npm.taobao.org/dist --global |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment