cnpm 安装
# cnpm 安装
前言
以下内容均来自 NPM MIRROR (opens new window) 官网
# 一. cnpm 是什么?
根据官方描述,这是一个完整 npmjs.org
镜像,你可以用此代替官方版本(只读),同步频率目前为 10分钟 一次以保证尽量与官方服务同步。
# 二. 安装
# 1. 使用 npm 安装(推荐👉)
使用阿里定制的 cnpm (opens new window) (gzip 压缩支持) 命令行工具代替默认的 npm:
$ npm install -g cnpm --registry=https://registry.npmmirror.com
1
# 2. 使用 npm 参数 alias
或者你直接通过添加 npm 参数 alias 一个新命令:
alias cnpm="npm --registry=https://registry.npmmirror.com \
--cache=$HOME/.npm/.cache/cnpm \
--disturl=https://npmmirror.com/mirrors/node \
--userconfig=$HOME/.cnpmrc"
# Or alias it in .bashrc or .zshrc
$ echo '\n#alias for cnpm\nalias cnpm="npm --registry=https://registry.npmmirror.com \
--cache=$HOME/.npm/.cache/cnpm \
--disturl=https://npmmirror.com/mirrors/node \
--userconfig=$HOME/.cnpmrc"' >> ~/.zshrc && source ~/.zshrc
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
# 三. 安装模块
$ cnpm install [name]
1
# 四. 同步模块
直接通过 sync
命令马上同步一个模块,只有 cnpm
命令才有此功能:
$ cnpm sync express
1
当然,你可以直接通过 web 方式来同步 /sync/express (opens new window)
$ open https://npmmirror.com/sync/express
1
# 五. 其他命令
支持 npm
除了 publish
之外的所有命令,如:
$ cnpm info express
1
上次更新: 2022/07/08, 18:18:02