{"record":{"id":"e97cb9719dc30f7a","repo":"calesthio/OpenMontage","slug":"error-npx-is-required-but-was-not-found-on-path","errorCode":null,"errorMessage":"Error: npx is required but was not found on PATH.","messagePattern":"Error: npx is required but was not found on PATH\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"render_demo.py","lineNumber":59,"sourceCode":"def find_command(*names: str) -> str | None:\n    for name in names:\n        resolved = shutil.which(name)\n        if resolved:\n            return resolved\n    return None\n\n\ndef ensure_demo_environment() -> str:\n    if not find_command(\"node\", \"node.exe\"):\n        raise SystemExit(\"Error: Node.js is required. Install it from https://nodejs.org/\")\n\n    npm_cmd = find_command(\"npm.cmd\", \"npm\", \"npm.exe\")\n    if not npm_cmd:\n        raise SystemExit(\"Error: npm is required but was not found on PATH.\")\n\n    npx_cmd = find_command(\"npx.cmd\", \"npx\", \"npx.exe\")\n    if not npx_cmd:\n        raise SystemExit(\"Error: npx is required but was not found on PATH.\")\n\n    if not (COMPOSER_DIR / \"node_modules\").exists():\n        print(\"Installing Remotion dependencies...\")\n        subprocess.run([npm_cmd, \"install\"], cwd=COMPOSER_DIR, check=True)\n\n    return npx_cmd\n\n\ndef validate_props_file(path: Path) -> None:\n    with path.open(\"r\", encoding=\"utf-8\") as handle:\n        payload = json.load(handle)\n\n    if not isinstance(payload.get(\"cuts\"), list) or not payload[\"cuts\"]:\n        raise SystemExit(f\"Error: {path} must define at least one cut.\")\n\n\ndef render_demo(name: str, props_path: Path, npx_cmd: str) -> None:\n    validate_props_file(props_path)","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/render_demo.py#L41-L77","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Upgrade to a current Node.js LTS (bundles node, npm, and npx together).","On Windows, ensure the Node install directory containing npx.cmd is on PATH.","In containers, use an official node image rather than a manually copied binary."],"exampleFix":"# shell — before\nnode --version   # v8.x -> no bundled npx\npython render_demo.py  # SystemExit: npx is required\n\n# shell — after\nnvm install --lts && nvm use --lts\npython render_demo.py","handlingStrategy":"validation","validationCode":"import shutil\n\nif not any(shutil.which(n) for n in (\"npx.cmd\", \"npx\", \"npx.exe\")):\n    raise SystemExit(\"npx not found — upgrade to a current Node.js LTS (bundles npx).\")","typeGuard":"import shutil\n\ndef npx_available() -> bool:\n    return any(shutil.which(n) for n in (\"npx.cmd\", \"npx\", \"npx.exe\"))","tryCatchPattern":"try:\n    npx = ensure_demo_environment()\nexcept SystemExit as e:\n    print(f\"Environment not ready: {e}\")\n    return 1","preventionTips":["Use a current Node LTS; npx has been bundled since npm 5.2.0.","Check `npx --version` alongside `node --version` in environment preflights.","Avoid partial Node installs copied binary-by-binary."],"tags":["environment","npx","prerequisites","rendering"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}