Skip to main content

Normalize Dependencies

Normalize dependency fields and optionally pin versions in workspace package.json files.

Summary

The normalize-dependencies recipe handles all dependency-related fields in each workspace's package.json.

It normalizes dependencies, devDependencies, peerDependencies, optionalDependencies, bundleDependencies (merging from the deprecated bundledDependencies form), and overrides.

When version pinning settings are enabled, it strips range prefixes (e.g., ^, ~) from dependency versions.

Behavior

For each eligible workspace, the recipe inspects every dependency-related field and applies the following rules. See Workspace Rules for how tags are determined.

  • dependencies (Conditional) — Removed if the field is present but empty.
  • devDependencies (Conditional) — Removed if the field is present but empty.
  • peerDependencies (Conditional) — Removed if the field is present but empty.
  • peerDependenciesMeta (Conditional) — Removed if the field is present but empty.
  • bundledDependencies (Conditional) — Merged into bundleDependencies (deduplicated), then deleted. If bundleDependencies is empty after the merge, it is also removed.
  • optionalDependencies (Conditional) — Removed if the field is present but empty.
  • overrides (Conditional) — Removed if the field is present but empty.

When pinDependencyVersions or pinDevDependencyVersions is enabled, the recipe also processes each version string in the respective group:

  • Range prefixes — Characters like ^, ~, >=, >, <=, < are stripped so the version resolves to an exact match.
  • file: references — Left untouched.
  • * and latest — Flagged as unpinnable. An error is logged and the process exit code is set to 1.
  • Already pinned — Versions that start with a digit or have no prefix are skipped.

Settings

Settings are configured per workspace in nova.config.json under the recipes key:

SettingTypeDescription
pinDependencyVersionsbooleanStrip range prefixes from dependencies versions.
pinDevDependencyVersionsbooleanStrip range prefixes from devDependencies versions.

Usage

Options

FlagDescription
-d, --dry-runPreview changes without modifying files.
-r, --replace-fileOverwrite the original file instead of creating a .nova-backup copy.