Skip to main content

Sync Environment

Sync engines, os, cpu, libc, devEngines, and packageManager fields in workspace package.json files.

Summary

The sync-environment recipe ensures that runtime environment fields in each workspace's package.json follow consistent conventions.

When the trackNodeLtsVersions setting is enabled, it automatically updates the engines.node constraint to match all currently active Node.js LTS versions.

Why Use This Command?

  1. Keeps Node.js engine support aligned with the active LTS policy chosen for each workspace.
  2. Normalizes platform constraints so package managers receive consistent runtime metadata.
  3. Keeps the project root on one validated Corepack client while removing duplicate manager declarations from child workspaces.
  4. Warns about incomplete LTS coverage before an outdated engine range reaches consumers.

Requirements

  • Node.js runtime — Use a supported Node.js LTS release with the Nova CLI available.
  • Project config — Register the workspace and enable recipes.package-json.<workspace>.sync-environment in nova.config.json.
  • Workspace manifest — The configured workspace must contain a readable package.json file.

Behavior

For each eligible workspace, the recipe inspects environment and runtime fields and applies the following rules. See Workspace Rules for how tags are determined.

  • packageManager (Required for project) — The project root accepts only an exact npm@version, pnpm@version, or yarn@version Corepack descriptor. A valid descriptor is preserved. A missing, ranged, partial, or unsupported value is replaced with the locally detected exact npm version in the same run. If npm version detection fails, Nova warns and leaves the field absent instead of guessing. Every non-project workspace has this field removed so the root remains the single source of truth.
  • engines (Required) — If missing, it is created. When active Node.js LTS versions are available, engines.node is set to the computed constraint. If engines exists but engines.node is missing, the constraint is added.
  • engines.node tracking — When trackNodeLtsVersions is enabled, the recipe checks whether the current engines.node value covers all active LTS major versions using >=N, ^N, ~N, N.x, or * patterns. If coverage is incomplete, a warning is logged. The value is then synced to the computed constraint.
  • os (Conditional) — Removed if the field is present but empty.
  • cpu (Conditional) — Removed if the field is present but empty.
  • libc (Required) — Removed if os does not include linux. If missing but os includes linux, it is added as ["glibc"].
  • devEngines (Conditional) — Removed if the field is present but empty.

Settings

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

SettingTypeDescription
trackNodeLtsVersionsbooleanAutomatically sync engines.node to current Node.js LTS versions.

Usage

Options

FlagDescription
-d, --dry-runRun without writing any files.
-r, --replace-fileOverwrite the original file instead of creating a .nova-backup copy.