yarn install
yarn install
用于安装一个项目的所有依赖。 当你检出项目代码,或者项目的其他开发者添加你要用到的新依赖时,这是最常用的。
如果习惯使用 npm 你可能希望使用 --save
或 --save-dev
。 这些已经被 yarn add
和 yarn add --dev
所取代。 更多信息,请参阅 yarn add
文档。
运行 yarn
不带命令将运行 yarn install
,并把参数标志传递给它。
yarn install
在本地 node_modules
目录安装 package.json
里列出的所有依赖。
yarn install --check-files
验证node_modules
中已经安装的文件没有被移除。
yarn install --flat
Install all the dependencies, but only allow one version for each package. 第一次运行这个命令时,会提示你在每个依赖包的多个版本范围中选择一个版本。 这会被添加到你的 package.json
文件的 resolutions
字段。
"resolutions": {
"package-a": "2.0.0",
"package-b": "5.0.0",
"package-c": "1.5.2"
}
yarn install --force
这回重新拉取所有包,即使之前已经安装的。
yarn install --har
从安装期间的所有网络请求输出一个 HTTP archive。 HAR 文件通常用于排查网络性能,并能用 Google’s HAR Analyzer 或 HAR Viewer 这样的工具分析。
yarn install --ignore-scripts
Do not execute any scripts defined in the project package.json and its dependencies.
yarn install --modules-folder <path>
Specifies an alternate location for the node_modules
directory, instead of the default ./node_modules
.
yarn install --no-lockfile
别阅读或生成 yarn.lock
文件。
yarn install --production[=true|false]
如果 NODE_ENV
环境变量是设为 production
,Yarn 不会安装在 devDependencies
中列出的任何包。 Use this flag to instruct Yarn to ignore NODE_ENV
and take its production-or-not status from this flag instead.
Notes:
--production
is the same as--production=true
.--prod
is an alias of--production
.
yarn install --pure-lockfile
别生成 yarn.lock
文件。
yarn install --ignore-engines
忽略引擎检查。
yarn install --offline
在离线模式下运行 yarn install。