Install devDependencies and Dependencies Together with Yarn

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.

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

yarn install --production=false should be helpful here I suppose. It should install both devDependencies and dependencies. Here is a link to the reference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sophia Al-Mansoor
Author

Sophia Al-Mansoor

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.