安装依赖
如果你刚刚从 版本控制 签出软件包,则需要安装这些依赖。
¥If you have just checked out a package from version control, you will need to install those dependencies.
如果你的项目是 添加依赖,那么这些依赖会在此过程中自动安装。
¥If you are adding dependencies for your project, then those dependencies are automatically installed during that process.
安装依赖
yarn install
用于安装项目的所有依赖。从项目的 package.json
文件中检索依赖,并将其存储在 yarn.lock
文件中。
¥yarn install
is used to install all dependencies for a project. The dependencies are retrieved from your project’s package.json
file, and stored in the yarn.lock
file.
开发包时,安装依赖通常是在以下之后完成:
¥When developing a package, installing dependencies is most commonly done after:
-
你刚刚签出了需要这些依赖才能运行的项目的代码。
¥You have just checked out code for a project that needs these dependencies to function.
-
该项目的另一位开发者添加了一个新的依赖,你需要选择该依赖。
¥Another developer on the project has added a new dependency that you need to pick up.
安装选件
安装依赖有很多选项,包括:
¥There are many options for installing dependencies, including:
-
安装所有依赖:
yarn
或yarn install
¥Installing all dependencies:
yarn
oryarn install
-
安装一个且仅一个版本的软件包:
yarn install --flat
¥Installing one and only one version of a package:
yarn install --flat
-
强制重新下载所有包:
yarn install --force
¥Forcing a re-download of all packages:
yarn install --force
-
仅安装生产依赖:
yarn install --production
¥Installing only production dependencies:
yarn install --production
请参阅 完整列表 个可传递给 yarn install
的标志。
¥See the full list of flags you can pass to yarn install
.