calesthio/OpenMontage · error · SystemExit

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

Error message

Error: npx 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 'npx.cmd', 'npx', 'npx.exe' resolves on PATH. npx ships with npm in modern Node distributions, so this fires in the same situations as the npm check: a partial or nonstandard Node installation where the npx launcher is missing even though node/npm were found. The script needs npx specifically to invoke the local Remotion CLI without a global install.

Source

Thrown at render_demo.py:59

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.")


def render_demo(name: str, props_path: Path, npx_cmd: str) -> None:
    validate_props_file(props_path)

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Upgrade to a current Node.js LTS (bundles node, npm, and npx together).
  2. On Windows, ensure the Node install directory containing npx.cmd is on PATH.
  3. In containers, use an official node image rather than a manually copied binary.

Example fix

# shell — before
node --version   # v8.x -> no bundled npx
python render_demo.py  # SystemExit: npx is required

# shell — after
nvm install --lts && nvm use --lts
python render_demo.py
Defensive patterns

Strategy: validation

Validate before calling

import shutil

if not any(shutil.which(n) for n in ("npx.cmd", "npx", "npx.exe")):
    raise SystemExit("npx not found — upgrade to a current Node.js LTS (bundles npx).")

Type guard

import shutil

def npx_available() -> bool:
    return any(shutil.which(n) for n in ("npx.cmd", "npx", "npx.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: node and npm resolve but the npx launcher doesn't — hand-copied node binary, an ancient Node version predating bundled npx (npm < 5.2.0), or Windows where the directory containing npx.cmd isn't on PATH.

Common situations: Very old Node installations; stripped container images; Windows PATH issues where npm is reachable via a shim but the nodejs bin dir with npx.cmd is not.

Related errors


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