Dependency Installation

Run the following to install all external dependencies listed in the workspace dependency policy, as well as those listed in the dependency graphs of your workspace components:

$bit
Copiedcopy
See command synopsis

The output lists the (direct) dependencies installed, as well as the main steps in the installation process:

Resolving component dependencies for workspace: 'my-workspace'
importing components
linking components
...

dependencies:
+ @teambit/eslint-config-bit-react 0.0.367
+ react 17.0.2 (18.2.0 is available)
+ react-dom 17.0.2 (18.2.0 is available)
...

devDependencies:
+ @types/jest 26.0.20 (29.1.1 is available)
...

installing dependencies using pnpm

A few things to notice:

  • ✔ importing components - this step imports all component snaps that have not been imported into the workspace, yet (either because the components are not up-to-date or because the workspace was just pulled from a traditional repository).
  • ✔ linking components - this step creates links from the node _modules directory to components maintained by the workspace. This enables you to consume components maintained in the same workspace, using a context-agnostic (absolute) package name.
  • ✔ installing dependencies using pnpm - dependency installation is done using the package manager of your choice (in this case, pnpm). Dependencies are installed in the workspace's node_modules directory.
Components vs packages

Components are installed as standard packages. However, since they are recognized by Bit as components, additional data is downloaded from their remote scopes. This data is used only for development.

Add an external dependency

To add a new external dependency run the following:

$bit
Copiedcopy
See command synopsis

The version installed defaults to the latest. To install a specific version, specify the version to install:

$bit
Copiedcopy
See command synopsis

The dependency is now added to the workspace dependency policy, and installed in the workspace node_modules directory. Components that have this dependency will resolve to this version (unless specified otherwise).

// workspace.jsonc
{
  "teambit.dependencies/dependency-resolver": {
    "policy": {
      "dependencies": {
        "lodash": "1.0.0"
      }
    }
  }
}
CopiedCopy

To configure dependencies on a specific group of components, and override the workspace dependency policy, see Dependency configuration (to install the configured dependencies, run bit install).

Update external dependencies

To update external dependencies that are listed in the workspace dependency policy, use the --update-existing / -u option:

$bit
Copiedcopy
See command synopsis

The newly installed versions are the latest versions available within the permissable semver range of each dependency.

To update an external dependency with a specific version, run:

$bit
Copiedcopy
See command synopsis

To review and select the outdated dependencies in the component dependency configuration, as well as in the workspace dependency policy, see Update dependencies.