NPM使用淘宝镜像的方法
如默
撰写于 2019年 10月 16 日

说明

npm源在国外,所以国内访问很慢,甚至很多依赖是无法安装的,所以使用国内淘宝源会方便很多,做个记录。

步骤

有很多方法来配置npm的registry地址,下面根据不同情境列出几种比较常用的方法。

临时使用

注意:原来的https://registry.npm.taobao.org已弃用

npm --registry https://registry.npmmirror.com install express

永久使用

npm config set registry https://registry.npmmirror.com

使用cnpm

npm install -g cnpm --registry=https://registry.npmmirror.com
cnpm是淘宝官方定制的一个命令行工具,支持除了publish之外的所有命令,使用时仅需要将npm替换为cnpm即可,但实际使用情况不佳,经常会出现很多莫名其妙的问题,不太建议使用

恢复默认

npm config set registry https://registry.npmjs.org

检测方法

查看源设置(两个命令都可以)

npm config get registry
npm info express

NPM使用淘宝镜像的方法

温馨提示:

本文最后更新于2019年10月16日,已超过1653天没有更新,若内容或图片失效,请留言反馈。

说明

npm源在国外,所以国内访问很慢,甚至很多依赖是无法安装的,所以使用国内淘宝源会方便很多,做个记录。

步骤

有很多方法来配置npm的registry地址,下面根据不同情境列出几种比较常用的方法。

临时使用

注意:原来的https://registry.npm.taobao.org已弃用

npm --registry https://registry.npmmirror.com install express

永久使用

npm config set registry https://registry.npmmirror.com

使用cnpm

npm install -g cnpm --registry=https://registry.npmmirror.com
cnpm是淘宝官方定制的一个命令行工具,支持除了publish之外的所有命令,使用时仅需要将npm替换为cnpm即可,但实际使用情况不佳,经常会出现很多莫名其妙的问题,不太建议使用

恢复默认

npm config set registry https://registry.npmjs.org

检测方法

查看源设置(两个命令都可以)

npm config get registry
npm info express


那年今日
10月
16日
赞 (0)

猜您想看

评论区(暂无评论)

这里空空如也,快来评论吧~

我要评论

Vaptcha 初始化中...