yarn 安装与更换源


安装

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM