当前位置:网站首页>yarn速查手册
yarn速查手册
2022-07-25 09:25:00 【一只小白菜~】
简单记录一下yarn的一些内容
yarn简述
Apache Hadoop YARN (Yet Another Resource Negotiator,另一种资源协调者)是一种新的 Hadoop 资源管理器,它是一个通用资源管理系统,可为上层应用提供统一的资源管理和调度,它的引入为集群在利用率、资源统一管理和数据共享等方面带来了巨大好处。
yarn是facebook发布的一款取代npm的包管理工具。
yarn–特点
- 速度快:Yarn缓存了每个下载过的包,所以再次使用时无需重复下载。同时利用并行下载以最大化资源利用率,因此安装快。
- 安全可靠:在执行代码之前,Yarn会通过算法检验每个安装包的完整性。yarn使用详细、简洁的锁文件格式和明确的安装算法,Yarn能够保证在不同系统上无差异工作。
yarn–安装
- 下载了nodejs然后使用npm进行安装:
npm install -g yarn yarn --version //查看版本 - 下载node.js然后下载yarn的安装程序—提供一个.msi文件在运行时引导安装Yarn
- Yarn淘宝源安装,分别复制黏贴以下代码到黑窗口运行即可:
yarn config set registry https://registry.npm.taobao.org -g yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g
Yarn–常用命令
- 初始化项目:
yarn init //同npm init,执行后会生成package.json文件 - 配置项:
yarn config list //显示所有配置项 yarn config get <key> //显示某配置项 yarn config delete <key> //删除某配置项 yarn config set <key> <value> [-g|--global] //设置配置项 - 安装包:
yarn install //安装package.json里所有包,并将包即它所有依赖项保存进yarn.lock yarn install --flat //安装一个包的单一版本 yarn install --force //强制重新下载所有包 yarn install --production //只安装dependencies里的包 yarn install --no-lockfile //不读取或生成yarn.lock yarn install --pure-lockfile //不生成yarn.lock - 添加包(会更新package.json 和 yarn.lock):
yarn add [package] //在当前项目中添加一个依赖包,会自动更新到package.json 和 yarn.lock文件中 yarn add [package]@[version] //安装指定版本,这里指的是主要版本,如果需要精确到小版本,使用 -E参数 yarn add [package]@[tag] //安装某个tag (比如beta,next或者latest) - 不指定依赖类型默认安装到dependencies里,你可以指定依赖类型:
yarn add --dev/-D //加到devDependencies yarn add --peer/-P //加到peerDependencies yarn add --optional /-O //加到optionalDependencies - 默认安装包的主要版本里的最新版本,下面两个命令可以指定版本:
yarn add --exact /-E //安装包的精确版本。例如: yarn add [email protected]会接受1.9.1版,但是yarn add [email protected] --exact直接说1.2.3版 yarn add --title /-T //安装包的次要版本里的最新版。例如:yarn add [email protected] --title 会接受1.2.9,但不接受1.3.0 - 发布包:
yarn publish - 删除包:
yarn remove [packageName] //移除一个包,会自动更新package.json 和 yarn.lock - 更新依赖:
yarn upgrade //用于更新包到基本规范范围的最新版本 - 运行:
yarn run //用来执行在package.json中scripts属性下定义的脚本 - 显示包信息:
yarn info <packageName> //可以用来查看某个模块的最新版本信息 - 缓存:
yarn cache list //列出已缓存的每个包 yarn cache dir //返回 全局缓存位置 yarn cache clean //清除缓存
npm 与 yarn 命令比较:
| npm | yarn | 命令说明 |
|---|---|---|
| npm init | yarn init | 初始化项目 |
| npm install/link | yarn install/link | 默认的安装依赖操作 |
| npm install xxx --save | yarn add xxx | 安装某个依赖,并且默认保存到package |
| npm uninstall xxx --save | yarn remove xxx | 移除某个依赖项目 |
| npm install xxx --save-dev | yarn add xxx --dev | 安装某个开发时依赖项目 |
| npm update xxx --save | yarn upgrade xxx | 更新某个依赖项目 |
| npm install xxx --global | yarn global add xxx | 安装某个全局依赖项目 |
| npm publish/login/logout | yarn publish/login/logout | 发布/登录/登出,一系列NPM Registry操作 |
| npm run/test | yarn run/test | 运行某个命令 |
npm 与 yarn 相关问题比较:
模块依赖历史依赖
比如说你的项目模块依赖:@1.2.1代表这个模块的版本。在你安装A的时候需要安装依赖C和D,很多依赖不会指定版本号,默认会安装最新的版本,这样就会出现出题:比如今天安装模块的时候C和D是某一个版本,而当以后C、D更新的时候,再次安装模块就会安装C和D的最新版本。如果新的版本无法兼容你的项目,你的程序可能就会出BUG,甚至无法运行。这就是npm弊端,而yarn为解决这个问题推出了yarn.lock的机制。
yarn版本升级降级命令
yarn 升级最新版本
npm install [email protected] -g
查看yarn历史版本
npm view yarn versions --json
yarn 升级指定版本 (例:升级到1.22.1版本)
yarn upgrade v1.22.1
yarn 降低到指定版本(先卸载,再安装)
npm uninstall yarn -g
npm install -g [email protected]1.3.2
如果yarn install有误时。可重新install或者清除 重新执行。
yarn install --force
yarn cache clean
边栏推荐
- 【机器翻译】SCONES——用多标签任务做机器翻译
- Mixed supervision for surface defect detection: from weakly to fully supervised learning
- T5 paper summary
- SystemVerilog语法
- Qt 6.2的下载和安装
- js利用requestAnimationFrame实时检测当前动画的FPS帧率
- Segmentation based deep learning approach for surface defect detection
- Fundamentals of C language
- MLX90640 红外热成像传感器测温模块开发笔记(二)
- ADC introduction
猜你喜欢

手持振弦采集仪对振弦传感器激励方法和激励电压

Mixed supervision for surface defect detection: from weakly to fully supervised learning

Camera attitude estimation

Mlx90640 infrared thermal imager temperature measurement module development instructions

Data viewing and parameter modification of multi-channel vibrating wire, temperature and analog sensing signal acquisition instrument

ESP32连接阿里云MQTT物联网平台

SD/SDIO/EMMC

工程监测多通道振弦传感器无线采集仪外接数字传感器过程

Arm preliminaries

JS uses requestanimationframe to detect the FPS frame rate of the current animation in real time
随机推荐
关闭brew执行命令时的自动更新
js利用requestAnimationFrame实时检测当前动画的FPS帧率
Camera attitude estimation
I2C也可总线取电!
FPGA基础进阶
canal实现mysql数据同步
NPM详解
小程序H5获取手机号方案
LoRA转4G及网关中继器工作原理
ISP image signal processing
framework打包合并脚本
看一个双非二本(0实习)大三学生如何拿到阿里、腾讯的offer
App lifecycle and appledelegate, scenedelegate
T5论文总结
Record of deep learning segment error (segment core/ exit code 139)
Swift simple implementation of to-do list
MLX90640 红外热成像传感器测温模块开发笔记(三)
ADC介绍
BSP3 电力监控仪(功率监控仪)端子定义和接线
SD/SDIO/EMMC