惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy International News Feed
爱范儿
爱范儿
H
Help Net Security
博客园 - 三生石上(FineUI控件)
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
GbyAI
GbyAI
T
Tenable Blog
Project Zero
Project Zero
腾讯CDC
Spread Privacy
Spread Privacy
V
Vulnerabilities – Threatpost
T
Threatpost
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Latest news
Latest news
L
Lohrmann on Cybersecurity
B
Blog RSS Feed
小众软件
小众软件
G
Google Developers Blog
T
Tor Project blog
P
Palo Alto Networks Blog
The Cloudflare Blog
Scott Helme
Scott Helme
D
Darknet – Hacking Tools, Hacker News & Cyber Security
A
Arctic Wolf
博客园 - 聂微东
AWS News Blog
AWS News Blog
L
LINUX DO - 热门话题
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
博客园 - Franky
Know Your Adversary
Know Your Adversary
人人都是产品经理
人人都是产品经理
博客园 - 【当耐特】
P
Privacy & Cybersecurity Law Blog
A
About on SuperTechFans
Cisco Talos Blog
Cisco Talos Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
量子位
C
Cisco Blogs
P
Proofpoint News Feed
雷峰网
雷峰网
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
B
Blog
Security Latest
Security Latest
C
Cybersecurity and Infrastructure Security Agency CISA
Jina AI
Jina AI
Y
Y Combinator Blog

梦魇小栈

《羊了个羊》程序员过关攻略 WebRTC 入门指南 将你的博客升级为 PWA 渐进式Web离线应用 什么? 微信没有年度账单? 前端 nodejs 撸起来~ [接口实现] Hexo 博客美化代码块 记一下 pm2 常用配置及命令 用 MySQL 导入 SQL 文件 解决 ubuntu 服务器中文乱码 面试分享:2018阿里巴巴前端面试总结(题目+答案) crontab 踩坑之绝对路径 SED 命令简明教程 在Hexo博客 NexT主题中部署Wildfire评论系统 使用 JavaScript 实现简单的拖拽 Merry Christmas JAVASCRIPT生成图形验证码 笔记:NPM版本号自增,自动化发布NPM包 不可不知的Mac OS X专用命令行工具(持续更新中) 继多说、网易关停之后该何去何从(网易云跟帖宣布2017年8月1日停止服务) 重新介绍 JavaScript(JS全面系列教程)
(译)NPM vs Yarn 备忘手册
Ihoey 心,若没有栖息的地方,到哪里都是流浪...... · 2018-04-28 · via 梦魇小栈

发表于 | 更新于 | 分类于 Node | 评论数: | 阅读次数:

原文链接: NPM vs Yarn Cheat Sheet

好,想必你对新的 JavaScript 包管理工具 yarn 已经有所耳闻,并已通过 npm i -g yarn 进行了安装,现在想知道怎么样使用吗?如果你了解 npm,你已经会很大一部分啦!

下面是我从 npm 切换到 yarn 的一些笔记。

👍 请收藏本文,本文会随着 yarn 的升级而更新。

备忘手册 - 你需要知道的

1
2
3
4
5
6
7
8
9
10
11
12
13
npm install === yarn
# 默认安装行为
npm install taco --save === yarn add taco
# 将 taco 安装并保存到 package.json 中
npm uninstall taco --save === yarn remove taco --save
# 在 npm 中,可以使用 npm config set save true 设置 —-save 为默认行为,但这对多数开发者而言并非显而易见的。在 yarn 中,在 package.json 中添加(add)和移除(remove)等行为是默认的。
npm install taco --save-dev === yarn add taco --dev
npm update --save === yarn upgrade
# update(更新) vs upgrade(升级), 赞!upgrade 才是实际做的事!版本号提升时,发生的正是 upgrade !
# 注意: npm update --save 在版本 3.11 中似乎有点问题。
npm install taco@latest --save === yarn add taco
npm install taco --global === yarn global add taco
# 一如既往,请谨慎使用 global 标记。

你可以使用 yarn self-update 来更新它自己

相同操作的命令

registry 的和 NPM 上是一样的。大致而言,Yarn 只是一个新的安装工具,NPM 结构和 registry 还是一样的。

1
2
3
4
5
6
7
8
9
10
npm init === yarn init
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
# 和 logout 是一样的
npm test === yarn test
npm install --production === yarn --production

Yarn 独有的命令

我跳过了一些提醒我们不要使用的内容,如 yarn clean

1
2
3
4
5
6
7
8
9
10
11
12
yarn licenses ls 
# 允许您检查您的依赖的许可证
yarn licenses generate-disclaimer 
# 自动创建您的许可证免责声明
yarn why taco 
# 确定为什么安装了 taco 检查为什么会安装 taco,详细列出依赖它的其他包(感谢 Olivier Combe).
Emojis ⬆️
速度 🏃⌁
通过 yarn lockfile 自动实现 shrinkwrap 功能
以安全为中心的设计
yarn upgrade-interactive
# 允许您自己选择升级指定的包

selectively upgrade specific packages

NPM 独有的命令

1
2
npm xmas === NO EQUIVALENT
npm visnup === NO EQUIVALENT

更多!

这篇备忘手册的 PDF 版本特别感谢 Justin Huskey

PDF文件链接

相关链接

https://yarn.bootcss.com/
https://github.com/yarnpkg/yarn

满分是10分的话,这篇文章你给几分,您的支持将鼓励我继续创作!

0%