What are dependencies and devDependencies in Yarn?

Yarn package manager

Yarn is a package manager introduced by Facebook. It is a more advanced package manager tool as compared to npm or Bower. The Yarn package manager allows the installation of packages offline if the package is available in the cache. It offers an improved network performance by retiring failed requests. It is also compatible with npm and Bower. Moreover, it checks for corrupt packages after each install.

Dependencies

These are the artifacts that are needed while running the code, e.g., React or ImmutableJS. We can add a dependency in the following way:

yarn add [package-name]

It will specify a dependency in the package.json file in the following way:

{
  "dependencies": {
    "[package-name]": "[package-version]"
  }
}

devDependencies

devDependencies are required in the development workflow, e.g., Babel or Flow. These packages will not be installed in production.

We can add a devDependency by specifying it with --dev, in the following way:

yarn add [package-name] --dev

The following will be available in the package.json file:

"devDependencies": {
"[package-name]": "[package-version]"
}

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved