Skip to content

Dependencies

Dependency management in oneRepo is optional, but builds upon your package manager in order to better manage choosing versions, overlap deduplication, and multi-workspace conveniences.

onerepo.config.js
export default {
dependencies: {
dedupe: true,
},
};

No configuration necessary! oneRepo automatically detects which package manager is used for your repository.

Aliases: one dependency, one deps, one dep

Safely manage Workspace dependencies across your repository.

Terminal window
one dependencies <command> [options...]

Add dependencies to Workspaces.

Terminal window
one dependencies add -w <workspace-names...> --dev [devDependencies...] --prod [prodDependencies...] [options...]

If a version is not provided with the command-line input, this command will look for currently installed versions of the requested dependencies throughout all Workspaces within the Workspace Graph. If only one version is found, it will be used, regardless of the --mode provided.

If multiple versions of the requested dependencies are found in the Workspace Graph, a prompt will be presented to choose the appropriate version.

Otherwise, the latest version will be requested from the registry.

OptionTypeDescription
--all, -abooleanRun across all Workspaces
--dedupeboolean, default: trueDeduplicate dependencies across the repository after install is complete.
--dev, -darrayAdd dependencies for development purposes only.
--mode"strict", "loose", "off", default: "loose"Version selection mode. Use strict to use strict version numbers, loose to use caret (^) ranges, and off for nothing specific.
--prod, -parrayAdd dependencies for production purposes.
--workspaces, -warrayOne or more Workspaces to add dependencies into

Install the latest version of normalizr from the registry, using a strict version number.

Terminal window
one dependencies add -w my-workspace -d normalizr --mode strict

Install the latest version of normalizr from the registry, using a caret (^) version number range, enabling newer minor and patch releases to satisfy the dependency in the future.

Terminal window
one dependencies add -w my-workspace -d normalizr --mode loose

Install react as a production dependency and babel-core as a development dependency in both workspace-a and workspace-b.

Terminal window
one dependencies add -w workspace-a workspace-b -d babel-core -p react

Remove dependencies from Workspaces.

Terminal window
one dependencies remove -w [workspaces...] -d [dependencies...] [options...]
OptionTypeDescriptionRequired
--all, -abooleanRun across all Workspaces
--dedupeboolean, default: trueDeduplicate dependencies across the repository after install is complete.
--dependencies, -darrayDependency names that should be removed.✅
--workspaces, -warrayList of Workspace names to run against

Verify dependencies across Workspaces.

Terminal window
one dependencies verify [options...]

Dependencies across Workspaces can be validated using one of the various modes:

  • off: No validation will occur. Everything goes.
  • loose: Reused third-party dependencies will be required to have semantic version overlap across unique branches of the Graph.
  • strict: Versions of all dependencies across each discrete Workspace dependency tree must be strictly equal.
OptionTypeDescription
--all, -abooleanRun across all Workspaces
--mode"strict", "loose", "off", default: "loose"Version selection mode. Use strict to use exact version matches, loose to accept within defined ranges (^ or ~ range), and off for no verification.
--workspaces, -warrayList of Workspace names to run against