yarn 安装与更换源 - develon - 博客园

本文介绍了如何在项目中切换Yarn和npm的源,推荐使用国内镜像加速依赖安装,并提到了淘宝npm镜像和cnpmjs镜像的使用方法。同时,针对npm更换源后搜索问题,给出了解决方案。

安装

https://classic.yarnpkg.com/zh-Hans/docs/install

查询与更换源

yarn config get registry

yarn config set registry https://registry.npm.taobao.org/

使用方法:安装依赖

下载所有依赖:

yarn install

添加一个依赖:

yarn add axios

npm更换源

npm也可以更换源,不过实测,更换源之后,搜索命令npm search无法使用,需要使用对应的网页搜索,要使用搜索,删除registry即可。

npm config get registry

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

恢复官方源

你可以这样设置官方源,从而恢复,不过,搜索依然无法使用:

yarn config set registry https://registry.yarnpkg.com
npm config set registry https://registry.npmjs.org

要恢复搜索功能,请使用删除:

yarn config delete registry
npm config delete registry

finaly

yarn无法搜索,npm换源后无法搜索,所以最终采用的方法是:
yarn更换源为国内镜像,npm保持搜索功能!

附录

淘宝npm镜像
·搜索地址:http://npm.taobao.org
·registry地址:http://registry.npm.taobao.org

cnpmjs镜像
·搜索地址:http://cnpmjs.org
·registry地址:http://r.cnpmjs.org

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

赢阡

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值