Yarn是什么?

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

build

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

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

打印依赖

yarn list

yarn 国内加速,修改镜像源

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

yarn config get registry

临时修改

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

全局修改

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

查看版本

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14

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