yarn basic

commands

1
2
3
yarn serve
# 打印 缓存 目录/路径
yarn cache dir

Yarn 是什么?

“Yarn 是由 Facebook、Google、Exponent 和 Tilde 联合推出了一个新的 JS 包管理工具, 正如官方文档中写的, Yarn 是为了弥补 npm 的一些缺陷而出现的。

build

1
2
yarn build
yarn build --report // 会在dist目录下生成一个report.html

npm, yarn 命令对照

https://classic.yarnpkg.com/zh-Hans/docs/migrating-from-npm/

npm 命令简写

https://www.jianshu.com/p/455f74669ce9

1
2
npm install 本身有一个别名,即 npm i
-S --save,缩写为-S,表示安装的包将写入 package.json 里面的 dependencies
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
npm install
yarn add

npm install --save algoliasearch/lite
yarn add algoliasearch/lite

npm install --save-dev 或 -D
yarn add <package...> [--dev/-D]

npm install --global http-server
yarn global add http-server

打印依赖树

1
yarn list

更新某个包的版本

1
yarn upgrade vuetify@v2.3.23

yarn 国内加速, 修改镜像源

以下命令查看当前使用的镜像源

yarn config get registry

临时修改

1
yarn save 软件名 --registry https://registry.npm.taobao.org/

全局修改

1
yarn config set registry https://registry.npm.taobao.org/

yarn add @angular-devkit/build-angular –dev

debian install yarn

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo “deb https://dl.yarnpkg.com/debian/ stable main” | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update && sudo apt-get install yarn

https://yarnpkg.com/zh-Hans/docs/install#debian-stable

archlinux

sudo pacman -S yarn

查看版本

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
yarn --version

yarn global add @angular/cli

add yarn global bin to path

vim .bashrc
export PATH=/home/wiloonwy/.yarn/bin:$PATH

yarn install: 安装 package.json 文件里定义的所有依赖。

yarn global bin # 输出 Yarn 已安装的可执行文件的符号链接位置

yarn config get registry
yarn config set registry 'https://registry.npm.taobao.org'



yarn config get registry

-> https://registry.yarnpkg.com

可以改成 taobao 的源: 

yarn config set registry "https://registry.npm.taobao.org"

-> yarn config v0.15.0

-> success Set "registry" to "https://registry.npm.taobao.org".

-> Done in 0.04s.

https://my.oschina.net/jiangxinxin/blog/775326

yarn vs npm

http://web.jobbole.com/88459/

yarn init private means adding a private: true field in the autogenerated package.json, which will instruct npm to refuse publishing the package to the public NPM registry on npm publish.

http://web.jobbole.com/88459/embed/#?secret=X3bbWZCgiD https://learnku.com/articles/15976/yarn-accelerate-and-modify-mirror-source-in-china https://stackoverflow.com/questions/51209962/whats-the-private-flag-yarn-init