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.
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.
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.
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.
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.
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. https://yarnpkg.com/lang/en/docs/cli/install/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With