Yarn 笔记之快速应用

yarn 的安装

1
brew install yarn

或者

1
npm install --global yarn

更多安装方式

1
yarn --version

设置淘宝源

1
2
3
4
5
6
# 查看源
$ yarn config get registry
https://registry.yarnpkg.com

# 设置源
$ yarn config set registry 'https://registry.npm.taobao.org'

新建新项目

1
yarn init

例子: CRUD(新增、查询、修改、删除)包

添加js包如(angular、jquery)

1
2
3
yarn add [package]
yarn add [package]@[version]
yarn add [package]@[tag]

查询

1
yarn list

升级js包

1
2
3
yarn upgrade [package]
yarn upgrade [package]@[version]
yarn upgrade [package]@[tag]

删除js包

1
yarn remove [package]

安装项目的js包(依籁关系)

1
yarn

1
yarn install

另个项目连接的当前项目中 yarn link

1
2
3
4
5
$ cd react
$ yarn link
yarn link vx.x.x
success Registered "react".
info You can now run `yarn link "react"` in the projects where you want to use this module and it will be used instead.
1
2
3
4
$ cd ../react-relay
$ yarn link react
yarn link vx.x.x
success Registered "react".

查看依籁关系(yarn why)

1
yarn why react

官方文档

参考:

https://yarnpkg.com/en/docs/usage

原文地址:http://dlj.bz/QCgBdp

Comments