calesthio/OpenMontage · error · SystemExit

Error: npm is required but was not found on PATH.

Error message

Error: npm is required but was not found on PATH.

What it means

Raised by render_demo.py's ensure_demo_environment() as SystemExit when none of 'npm.cmd', 'npm', 'npm.exe' resolves on PATH. npm normally ships inside the Node.js distribution, so this usually means Node is installed in a nonstandard way (node binary copied without its npm sibling), PATH points at a partial Node install, or on Windows npm exists only as npm.cmd in a directory not on PATH.

Source

Thrown at render_demo.py:55

        return {}
    return {path.stem: path for path in sorted(PROPS_DIR.glob("*.json"))}


def find_command(*names: str) -> str | None:
    for name in names:
        resolved = shutil.which(name)
        if resolved:
            return resolved
    return None


def ensure_demo_environment() -> str:
    if not find_command("node", "node.exe"):
        raise SystemExit("Error: Node.js is required. Install it from https://nodejs.org/")

    npm_cmd = find_command("npm.cmd", "npm", "npm.exe")
    if not npm_cmd:
        raise SystemExit("Error: npm is required but was not found on PATH.")

    npx_cmd = find_command("npx.cmd", "npx", "npx.exe")
    if not npx_cmd:
        raise SystemExit("Error: npx is required but was not found on PATH.")

    if not (COMPOSER_DIR / "node_modules").exists():
        print("Installing Remotion dependencies...")
        subprocess.run([npm_cmd, "install"], cwd=COMPOSER_DIR, check=True)

    return npx_cmd


def validate_props_file(path: Path) -> None:
    with path.open("r", encoding="utf-8") as handle:
        payload = json.load(handle)

    if not isinstance(payload.get("cuts"), list) or not payload["cuts"]:
        raise SystemExit(f"Error: {path} must define at least one cut.")

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Reinstall Node.js from the official installer/package manager so node and npm land in the same directory on PATH.
  2. On Windows, verify the Node install dir (e.g. C:\Program Files\nodejs) containing npm.cmd is on PATH.
  3. In stripped containers, switch to a full node image (e.g. node:<version>-slim) instead of a hand-copied binary.

Example fix

# Dockerfile — before
COPY node /usr/local/bin/node  # npm missing

# Dockerfile — after
FROM node:22-slim
RUN apt-get update && apt-get install -y python3
Defensive patterns

Strategy: validation

Validate before calling

import shutil

if not any(shutil.which(n) for n in ("npm.cmd", "npm", "npm.exe")):
    raise SystemExit("npm not found — reinstall Node.js so node and npm share a directory on PATH.")

Type guard

import shutil

def npm_available() -> bool:
    return any(shutil.which(n) for n in ("npm.cmd", "npm", "npm.exe"))

Try / catch

try:
    npx = ensure_demo_environment()
except SystemExit as e:
    print(f"Environment not ready: {e}")
    return 1

Prevention

When it happens

Trigger: Running render_demo.py when node resolves but the npm launcher script doesn't — e.g. a manually extracted node binary, a stripped-down container image, or Windows where the npm.cmd directory (nodejs install dir) isn't on PATH.

Common situations: Docker images that copy only the node binary; Windows PATH edited to include a different directory than the one holding npm.cmd; broken half-updated Node installation.

Related errors


AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15). Data as JSON: /api/errors/a7dec579cb8d87d4. Report an issue: GitHub.