(React-Native 学习之三) Yarn 和 npm 相关命令 以及区别
来源:互联网 发布:网络延迟100多 编辑:程序博客网 时间:2024/05/17 07:04
前言 :Yarn是Facebook提供的替代npm的工具,可以加速node模块的下载。React Native的命令行工具用于执行创建、初始化、更新项目、运行打包服务(packager)等任务。
一,需要了解的命令:
npm install === yarn —— install 安装是默认行为。npm install taco --save === yarn add taco —— taco 包立即被保存到 package.json 中。npm uninstall taco --save === yarn remove taco在 npm 中,可以使用 npm config set save true 设置 —-save 为默认行为,但这对多数开发者而言并非显而易见的。在 yarn 中,在package.json 中添加(add)和移除(remove)等行为是默认的。
npm install taco --save-dev === yarn add taco --devnpm update --save === yarn upgradeupdate(更新) vs upgrade(升级), 赞!upgrade 才是实际做的事!版本号提升时,发生的正是upgrade!注意: npm update --save 在版本 3.11 中似乎有点问题。
npm install taco@latest --save === yarn add taconpm install taco --global === yarn global add taco —— 一如既往,请谨慎使用 global 标记。
二,已知悉的命令:
包和 npm registry 上是一样的。大致而言,Yarn 只是一个新的安装工具,npm 结构和 registry 还是一样的。npm init === yarn initnpm link === yarn linknpm outdated === yarn outdatednpm publish === yarn publishnpm run === yarn runnpm cache clean === yarn cache cleannpm login === yarn login (logout 同理)npm test === yarn test
三,Yarn 独有的命令:
我跳过了一些提醒我们不要使用的内容,如 yarn clean。
yarn licenses ls —— 允许你检查依赖的许可信息。yarn licenses generate —— 自动创建依赖免责声明 license。yarn why taco —— 检查为什么会安装 taco,详细列出依赖它的其他包(鸣谢 Olivier Combe)。Emojis速度通过 yarn lockfile 自动实现 shrinkwrap 功能以安全为中心的设计Npm 独有的命令npm xmas === NO EQUIVALENTnpm visnup === NO EQUIVALENT笔者写作本文时, yarn 的 run 命令似乎出了点问题,应该会在 0.15.2 中修复。在这一点上, npm 好多了。感谢 Zachary 的研究!
四,npm 与 yarn 命令对比:
还有更多呢:
值得一看:
Yehuda Katz using Yarn — http://yehudakatz.com/2016/10/11/im-excited-to-work-on-yarn-the-new-js-package-manager-2/
Facebook Announce — https://code.facebook.com/posts/1840075619545360
News — http://thenextweb.com/dd/2016/10/12/facebook-launches-yarn-a-faster-npm-client/
Benchmarking — https://www.berriart.com/blog/2016/10/npm-yarn-benchmark/
进阶阅读:
https://yarnpkg.com/en/docs/
https://twitter.com/yarnpkg
https://github.com/yarnpkg/yarn
https://yarnpkg.com/en/docs/migrating-from-npm
转载和参考:
https://segmentfault.com/a/1190000007218841
https://segmentfault.com/a/1190000008632323
阅读全文
0 0
- (React-Native 学习之三) Yarn 和 npm 相关命令 以及区别
- React Native 相关命令:
- mac下npm install -g yarn react-native-cli出错
- React Native 下载组件以及npm常用命令
- React-Native UI学习之轮播图(三)
- React Native学习三
- React Native 学习三
- react native组件学习(三)
- 学习总结 ~ (三)React Native 初学 之 sectionList
- react从零到native--npm及webpack学习
- react和react-native样式区别
- npm和yarn
- react native手动 npm init
- npm下载react-native 慢
- react native之API学习
- react native学习之Toast
- React native之IntentAndroid学习
- 学习react-native之Navigator
- MySQL高可用工具heartbeat简介
- UItableView时键盘遮挡 iOS11下刷新滚动
- stm32 keil中出现use of undeclared identifier' '的原因
- python常用模块
- 深度学习4:神经网络的架构和类型
- (React-Native 学习之三) Yarn 和 npm 相关命令 以及区别
- hdu 6241
- 【论文阅读】A Correlated Topic Model Using Word Embeddings
- arduino开发板安装驱动
- Spring Boot 日志记录 SLF4J
- python操作redis
- JAVA必背面试题和项目面试通关要点
- java集合
- 关键字查找