如何安装NPM淘宝镜像,使用cnpm进行模块安装

版权声明:本文为博主原创文章,欢迎转载,转载请标明出处。 https://blog.csdn.net/YeShenLiaoSuiFeng/article/details/80313855

你可以使用淘宝的定制的 cnpm (gzip 压缩支持) 命令行工具代替默认的 npm:

$ 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

安装模块

$ cnpm install [name]  简写 cnpm i [name]

猜你喜欢

转载自blog.csdn.net/YeShenLiaoSuiFeng/article/details/80313855
今日推荐