简体   繁体   English

纱线制造和纱线安装有什么区别?

[英]What is the difference between yarn build and yarn install?

这两个到底是做什么的,在哪里使用它们?

  • yarn install

  • yarn build

In a nutshell, yarn install is the command used to install all dependencies for a project, usually allocated in the package.json file. 简而言之, yarn install是用于安装项目的所有依赖项的命令,通常在package.json文件中分配。 In most scenarios it is because you cloned a project and need its dependencies installed to run it. 在大多数情况下,这是因为您克隆了一个项目并需要安装其依赖项才能运行它。

On the other hand, yarn build is not a built-in command in the Yarn package manager . 另一方面, yarn build不是Yarn程序包管理器中的内置命令。 Looking at your question, it seems like you are running some #reactjs project, which might have defined a build command in its package.json file. 查看您的问题,似乎您正在运行一些#reactjs项目,该项目可能已在其package.json文件中定义了一个build命令。

I hope this clarifies your doubt, but for a complete answer, please provide an example of what is your specific scenario. 我希望这可以澄清您的疑问,但是对于完整的答案,请举例说明您的具体情况。

Also be aware that when running custom scripts like build, test, deploy, etc. it is recommended tu use the yarn run [script] command as stated in the Yarn docs , in your case yarn run build . 还应注意,在运行自定义脚本(如构建,测试,部署等)时,建议您按照Yarn文档中的说明使用yarn run [script]命令,在这种情况下,最好使用yarn run build

yarn install is used to fetch and install all dependencies for your project which are defined in your package.json . yarn install用于获取和安装package.json中定义的项目的所有依赖项。 You might want to do this when you add a dependency or if you freshly checked out the project on another computer. 添加依赖项或在另一台计算机上刚签出项目时,可能要执行此操作。 Also read the docs on yarn install. 另请阅读有关yarn install 的文档

yarn run build calls the script that you configured for the "build" command in your package.json . yarn run build调用在package.json中为“ build”命令配置的脚本。 Note that yarn build is not a valid yarn command. 请注意, 建立纱线不是有效的纱线命令。

{
  "name": "my-package",
  "scripts": {
    "build": "babel src -d lib" // <-- this will be executed
  }
}

Also see the yarn run documentation 另请参见纱线运行文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM