yarn的使用方法

Installation

MacOS

brew install yarn

Upgrade

MacOS

brew upgrade yarn

yarn --version

Usage

Starting a new project

yarn init

Adding a dependency

yarn add [package]

yarn add [package]@[version]

yarn add [package]@[tag]

Adding a dependency to different categories of dependencies

yarn add [package] --dev

yarn add [package] --peer

yarn add [package] --optional

Upgrading a dependency

yarn upgrade [package]

yarn upgrade [package]@[version]

yarn upgrade [package]@[tag]

Removing a dependency

yarn remove [package]

Installing all the dependencies of project

yarn or yarn install

Migrating from npm

If you want to try Yarn out on your existing npm project, just try running:

yarn

This will lay out your node_modules folder using Yarn's resolution algorithm that is compatible with the node.js module resolution algorithm.

Later, if you decide that Yarn is not for you, you can just go back to using npm without making any particular changes. You can delete your old yarn.lock file if nobody on the project is using Yarn any more but it's not necessary.

Reference:

https://yarnpkg.com/en/docs/getting-started

相关推荐
J***Q2921 小时前
Vue数据可视化
前端·vue.js·信息可视化
ttod_qzstudio3 小时前
深入理解 Vue 3 的 h 函数:构建动态 UI 的利器
前端·vue.js
_大龄3 小时前
前端解析excel
前端·excel
一叶茶4 小时前
移动端平板打开的三种模式。
前端·javascript
前端大卫4 小时前
一文搞懂 Webpack 分包:async、initial 与 all 的区别【附源码】
前端
Want5954 小时前
HTML音乐圣诞树
前端·html
老前端的功夫4 小时前
前端浏览器缓存深度解析:从网络请求到极致性能优化
前端·javascript·网络·缓存·性能优化
Running_slave5 小时前
你应该了解的TCP滑窗
前端·网络协议·tcp/ip
程序员小寒6 小时前
前端高频面试题之CSS篇(一)
前端·css·面试·css3
颜酱6 小时前
Monorepo 架构以及工具选型、搭建
前端·javascript·node.js