lerna ERR! yarn install --mutex network:42424 --non-interactive exited 1
查明原因是:yarn的版本问题造成的,切换到稳定版本
# yarn 升级最新版本
npm install yarn@latest -g
# 查看yarn历史版本
npm view yarn versions --json
# yarn 升级指定版本 (例:升级到1.21.3版本)
yarn upgrade v1.21.3
(稳定版本可参考yarn中文网)
https://yarn.bootcss.com/docs/install/#windows-stable](https://yarn.bootcss.com/docs/install/#windows-stable)
一. npm和yarn源的简单修改(以淘宝镜像为例)
npm
1. 临时修改(只生效一次)
npm install 包的名字 --registry https://registry.npm.taobao.org
2. 设置npm的配置项(全局配置)
查看npm源的当前地址
npm config get registry
设置淘宝镜像
npm config set registry https://registry.npm.taobao.org
yarn
1. 临时修改(只生效一次)
yarn save 包的名字 --registry https://registry.npm.taobao.org/
2. 设置yarn的配置项(全局配置)
查看yarn源的当前地址
yarn config get registry
设置淘宝镜像
yarn config set registry https://registry.npm.taobao.org/
二. 使用第三方软件快速修改、切换 npm和yarn的源(以淘宝镜像为例)
(1)分别修改npm和yarn源(经实际测试,这种方法修改一个源另一个源也会同时修改)
npm
nrm 是一个 NPM 源管理器,允许你快速地在如下 NPM 源间切换
安装
npm install -g nrm
列出可选的源
nrm ls
* npm ---- https://registry.npmjs.org/
cnpm --- http://r.cnpmjs.org/
taobao - https://registry.npm.taobao.org/
nj ----- https://registry.nodejitsu.com/
rednpm - http://registry.mirror.cqupt.edu.cn/
npmMirror https://skimdb.npmjs.com/registry/
edunpm - http://registry.enpmjs.org/
带 * 的是当前使用的源
切换
切换到taobao镜像源
nrm use taobao
Registry has been set to: https://registry.npm.taobao.org/
测试源的响应时间
测试所有源的响应时间:
nrm test
npm ---- 2930ms
cnpm --- 300ms
* taobao - 292ms
nj ----- Fetch Error
rednpm - Fetch Error
npmMirror 1626ms
edunpm - Fetch Error
可以多次测量来得到更精确的结果
更多nrm使用方法访问nrm的gitHub仓库
https://github.com/Pana/nrm
yarn
yrm 是一个 yarn源管理器,允许你快速地在yarn源间切换
安装
npm install -g yrm
列出可选的源
yrm ls
npm ---- https://registry.npmjs.org/
cnpm --- http://r.cnpmjs.org/
* taobao - https://registry.npm.taobao.org/
nj ----- https://registry.nodejitsu.com/
rednpm - http://registry.mirror.cqupt.edu.cn/
npmMirror https://skimdb.npmjs.com/registry/
edunpm - http://registry.enpmjs.org/
yarn --- https://registry.yarnpkg.com
带 * 的是当前使用的源
切换
切换到taobao镜像源
yrm use taobao
YARN Registry has been set to: https://registry.npm.taobao.org/
测试源的响应时间
测试所有源的响应时间:
yrm test
npm ---- 784ms
cnpm --- 290ms
* taobao - 297ms
nj ----- Fetch Error
rednpm - Fetch Error
npmMirror 1353ms
edunpm - Fetch Error
yarn --- Fetch Error
可以多次测量来得到更精确的结果
更多yrm使用方法访问yrm的gitHub仓库
https://github.com/i5ting/yrm
(2)使用双源管理工具cgr (特感谢缤纷扫落叶推荐)
安装
npm install -g cgr
Yarn 常用命令
npm install === yarn —— install安装是默认行为
npm install taco --save === yarn add taco —— taco包立即被保存到 package.json 中。
npm uninstall taco --save === yarn remove taco
npm install taco --save-dev === yarn add taco --dev
npm update --save === yarn upgrade
npm install taco@latest --save === yarn add taco
npm install taco --global === yarn global add taco —— 一如既往,请谨慎使用 global 标记。
注意:使用yarn或yarn install安装全部依赖时是根据package.json里的"dependencies"字段来决定的
npm init === yarn init
npm init --yes/-y === yarn init --yes/-y
npm link === yarn link
npm outdated === yarn outdated
npm publish === yarn publish
npm run === yarn run
npm cache clean === yarn cache clean
npm login === yarn login
npm test === yarn test
Yarn 独有的命令
yarn licenses ls —— 允许你检查依赖的许可信息
yarn licenses generate —— 自动创建依赖免责声明 license
yarn why taco —— 检查为什么会安装 taco,详细列出依赖它的其他包
yarn why vuepress —— 检查为什么会安装 vuepress,详细列出依赖它的其他包
特性
Yarn 除了让安装过程变得更快与更可靠,还添加了一些额外的特性,从而进一步简化依赖管理的工作流。
网友评论