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

相关推荐
旷世奇才李先生11 分钟前
Vue 3\+Vite\+Pinia实战:前端工程化与组件化开发全指南
前端·vue.js
Beginner x_u16 分钟前
前端八股整理(手写 01)|Promise 超时控制、红绿灯与 Promise.all
前端·javascript·promise
万少10 小时前
Vibe Coding不停歇,移动端 TRAE SOLO 让你用手机也能编程啦
前端·javascript·后端
kyriewen1110 小时前
WebAssembly:前端界的“外挂”,让C++代码在浏览器里跑起来
开发语言·前端·javascript·c++·单元测试·ecmascript
烛衔溟11 小时前
TypeScript 接口的基本使用 —— 定义对象形状
前端·javascript·typescript
铁皮饭盒11 小时前
成为AI全栈 - 第3课:路由 RESTful Elysia 状态码 设计规范
前端·后端·全栈
顾昂_12 小时前
Web 性能优化完全指南
前端·面试·性能优化
前端程序媛-Tian12 小时前
前端 AI 提效实战:从 0 到 1 打造团队专属 AI 代码评审工具
前端·人工智能·ai
支付宝体验科技12 小时前
Ant Design Pro v6.0.0 发布
前端
T畅N13 小时前
审批流设计器(前端)
前端·elementui·vue·html·流程图·js