Controlling dependencies

Bit simplifies dependency management for your components. It automatically detects dependencies while giving you granular control over versions and overrides for individual components or groups.

Dependency resolution relies on two configuration files:

  • workspace.jsonc: Defines allowed dependency versions within the workspace, primarily for runtime dependencies like lodash or classnames.
  • env.jsonc: Configures the component development environment, mostly specifying peer dependencies like React, GraphQL, TypeScript, or Vitest.

To manually manage dependencies, use the bit deps command. For instance, to add the classnames package to the apps/to-do component, run:

$bit
Copiedcopy
See command synopsis

This command defaults to the latest classnames version. You'll see a confirmation message indicating the added dependency and its version in the apps/to-do component's dependency graph.

Setting version or range

To add a dependency with a specific semantic version (semver) or range:

$bit
Copiedcopy

Peer and dev dependencies

While it's recommended to manage peer and dev dependencies through your component's development environment configuration file, you can directly set them using the --peer or --dev flags:

$bit
Copiedcopy
See command synopsis

Setting dependencies across components

To set a dependency for a group of components using a glob pattern:

$bit
Copiedcopy

Remove dependencies

Force remove specific dependency for a component:

$bit
Copiedcopy
See command synopsis

To reset all manually configured dependencies for a component:

$bit
Copiedcopy
See command synopsis