简体   繁体   English

将 devDependencies 和依赖项与 yarn 一起安装

[英]Install devDependencies and dependencies together with yarn

Is it possible to install devDependencies and dependencies together with yarn?是否可以将devDependenciesdependencies项与 yarn 一起安装?

For example, if I want to install react and webpack .例如,如果我想安装reactwebpack React is a dependency and webpack is a dev dependency. React 是一个依赖项,而 webpack 是一个开发依赖项。 To install both, I need to run these two commands要安装两者,我需要运行这两个命令

yarn add react
yarn add webpack -D

Is is possible to combine them into one command or is there any alternative?是否可以将它们组合成一个命令或者是否有任何替代方法? Like installing both devDependencies and dependencies at the same time without running multiple commands.就像在不运行多个命令的情况下同时安装 devDependencies 和依赖项一样。

I don't think it is possible.我不认为这是可能的。 Documentation does not specify such option, and if you provide at least one flag modifying type of dependencies - all dependencies specified in a command will become this type.文档没有指定这样的选项,并且如果您提供至少一个标志修改依赖类型 - 在命令中指定的所有依赖都将成为这种类型。 If you really want to be one command to paste into command line you could do this:如果你真的想成为一个粘贴到命令行的命令,你可以这样做:

yarn add react && yarn add webpack -D

yarn install --production=false should be helpful here I suppose.我想yarn install --production=false在这里应该会有所帮助。 It should install both devDependencies and dependencies .它应该安装devDependenciesdependencies Here is a link to the reference.这是参考的链接。 https://yarnpkg.com/lang/en/docs/cli/install/ https://yarnpkg.com/lang/en/docs/cli/install/

我认为yarn add --dev @packageName应该可以

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

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