javascript 为什么当我只需要构建时,yarn 会安装开发依赖项?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49530678/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why will yarn install dev dependencies when I just need the builds?
提问by vdegenne
If I invoke yarn add <my-package>, Yarnwill install both dependencies and devDependencies of <my-package>. Is it normal behavior ?
如果我调用yarn add <my-package>,Yarn将安装<my-package>. 这是正常行为吗?
I checked the documentation but I couldn't find a way to prevent it from installing the development dependencies (which I don't need). I believe devDependenciesare the dependencies that were used to compile the sources into the build scripts. And building my app I just need the builds.
我检查了文档,但找不到阻止它安装开发依赖项(我不需要)的方法。我相信devDependencies是用于将源代码编译到构建脚本中的依赖项。构建我的应用程序我只需要构建。
回答by kimy82
Use --production=true(or simply --productionor --prodfor short). It is indeed normal behaviour; Yarn assumes you are in a 'development' context unless your NODE_ENV environment variable is set to 'production'.
使用--production=true(或简单地--production或--prod简称)。这确实是正常的行为;Yarn 假定您处于“开发”上下文中,除非您的 NODE_ENV 环境变量设置为“生产”。
Have a look at Yarn's documentation.
看看 Yarn 的文档。

