Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install devDependencies and dependencies together with yarn

Is it possible to install devDependencies and dependencies together with yarn?

For example, if I want to install react and webpack. React is a dependency and webpack is a dev dependency. 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.

like image 358
Pranesh Ravi Avatar asked Apr 10 '18 04:04

Pranesh Ravi


People also ask

Which command will install both dependencies and devDependencies?

To add dependencies and devDependencies to a package. json file from the command line, you can install them in the root directory of your package using the --save-prod flag for dependencies (the default behavior of npm install ) or the --save-dev flag for devDependencies.

How do you add devDependencies to yarn?

You can also add other types of dependencies using flags: yarn add --dev to add to devDependencies. yarn add --peer to add to peerDependencies. yarn add --optional to add to optionalDependencies.

Can I use npm install and yarn together?

Yarn can consume the same package. json format as npm, and can install any package from the npm registry. This will lay out your node_modules folder using Yarn's resolution algorithm that is compatible with the node.

Does yarn start install dependencies?

yarn install is used to install all dependencies for a project. This is most commonly used when you have just checked out code for a project, or when another developer on the project has added a new dependency that you need to pick up.


2 Answers

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 
like image 171
Kacper Wiszczuk Avatar answered Sep 22 '22 23:09

Kacper Wiszczuk


yarn install --production=false should be helpful here I suppose. It should install both devDependencies and dependencies. Here is a link to the reference. https://yarnpkg.com/lang/en/docs/cli/install/

like image 24
Sushim Mukul Dutta Avatar answered Sep 22 '22 23:09

Sushim Mukul Dutta