如果习惯使用 npm, 你可能希望使用 —save—save-dev, 这些已经被 yarn addyarn add —dev 所取代。 更多信息,请参阅 yarn add 文档

执行不带任何命令的yarn,等同于执行yarn install,并透传所有参数。

如果需要可重现的依赖环境(比如在持续集成系统中),应该传入 —frozen-lockfile 标志。

yarn install

在本地 目录安装 package.json 里列出的所有依赖。

yarn install —check-files

验证 node_modules 中已安装的文件没有被移除。

yarn install —flat

安装所有依赖,但每个依赖只允许有一个版本存在。 第一次运行这个命令时,会提示你在每个依赖包的多个版本范围中选择一个版本。 这会被添加到你的 package.json 文件的 resolutions 字段。

yarn install —force
yarn install —har

从安装期间的所有网络请求输出一个 。 HAR 文件通常用于排查网络性能,并能用 Google’s HAR Analyzer 或 这样的工具分析。

yarn install —ignore-scripts

不执行项目 package.json 及其依赖定义的任何脚本。

yarn install —modules-folder <path>

node_modules 目录指定另一位置,代替默认的 ./node_modules

yarn install —no-lockfile

不读取或生成 yarn.lock 锁文件。

yarn install —production[=true|false]

如果 NODE_ENV 环境变量设为 ,Yarn 将不安装任何列于 devDependencies 的包。 使用此标志指示 Yarn 忽略 NODE_ENV 并用它取代“生产”与否的状态。

yarn install —pure-lockfile

不生成 yarn.lock 锁文件。

yarn install —frozen-lockfile
yarn install —silent

执行 yarn install 而不显示安装日志

yarn install —ignore-engines

忽略引擎检查。

yarn install —ignore-optional

Don’t install optional dependencies.

yarn install —offline

Run yarn install in offline mode.

yarn install —non-interactive

Disable interactive prompts, like when there’s an invalid version of a dependency.

yarn install —update-checksums

Update checksums in the lockfile if there’s a mismatch between them and their package’s checksum.