{"record":{"id":"43b83df3380b9bb4","repo":"nikivdev/code","slug":"bun-or-npm-is-required-to-install-docs-hub-depende","errorCode":null,"errorMessage":"bun or npm is required to install docs hub dependencies","messagePattern":"bun or npm is required to install docs hub dependencies","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/docs.rs","lineNumber":545,"sourceCode":"    if let Some(pid) = load_docs_hub_pid()? {\n        terminate_process(pid).ok();\n        remove_docs_hub_pid().ok();\n    }\n    kill_docs_hub_by_port(4410).ok();\n    Ok(())\n}\n\nfn ensure_docs_hub_deps(hub_root: &Path) -> Result<()> {\n    let node_modules = hub_root.join(\"node_modules\");\n    if node_modules.exists() {\n        return Ok(());\n    }\n    if which(\"bun\").is_ok() {\n        run_command(\"bun\", &[\"install\"], hub_root)\n    } else if which(\"npm\").is_ok() {\n        run_command(\"npm\", &[\"install\"], hub_root)\n    } else {\n        bail!(\"bun or npm is required to install docs hub dependencies\");\n    }\n}\n\nfn run_docs_hub_dev(hub_root: &Path, host: &str, port: u16, no_open: bool) -> Result<()> {\n    let mut cmd = if which(\"bun\").is_ok() {\n        let port_arg = port.to_string();\n        let host_arg = host.to_string();\n        let mut cmd = Command::new(\"bun\");\n        cmd.args([\n            \"run\",\n            \"dev\",\n            \"--\",\n            \"--port\",\n            &port_arg,\n            \"--hostname\",\n            &host_arg,\n        ]);\n        cmd","sourceCodeStart":527,"sourceCodeEnd":563,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/docs.rs#L527-L563","documentation":"ensure_docs_hub_deps requires bun or npm to install the docs hub's JavaScript dependencies. If neither executable is found on PATH (via the `which` crate), it bails rather than attempting the install, since there is no supported fallback package manager.","triggerScenarios":"Running run_docs_hub, ensure_docs_hub_daemon_with_focus, or deploy_docs_hub on a machine without bun and without npm installed, or where neither is on the PATH of the process (e.g. launched from a daemon/systemd unit with a minimal PATH).","commonSituations":"Fresh CI container or server image without Node.js tooling; nvm-managed node not loaded in non-interactive shells; running the tool inside Docker with a slim base image; PATH stripped when invoked from a GUI app or cron.","solutions":["Install bun (curl -fsSL https://bun.sh/install | bash) or Node.js/npm and ensure it is on PATH","If the tool is run from a service/daemon, set PATH explicitly (e.g. PATH=/usr/local/bin:/usr/bin:...) in the unit or wrapper","If using nvm, source nvm in the shell profile or symlink node/npm into /usr/local/bin","Verify with `which bun || which npm` before invoking the hub command"],"exampleFix":"// before: shell without node tooling\n$ which npm\n(not found)\n// after\n$ curl -fsSL https://bun.sh/install | bash\n$ export PATH=\"$HOME/.bun/bin:$PATH\"\n$ mytool docs hub  # bun found, deps installed","handlingStrategy":"validation","validationCode":"use std::process::Command;\nfn has(cmd: &str) -> bool { Command::new(\"which\").arg(cmd).output().map(|o| o.status.success()).unwrap_or(false) }\nif !has(\"bun\") && !has(\"npm\") {\n    eprintln!(\"install bun or Node.js before running the docs hub\");\n    return;\n}\nrun_docs_hub(&opts)?;","typeGuard":null,"tryCatchPattern":"match ensure_docs_hub_deps(&hub_root) {\n    Ok(()) => {}\n    Err(e) if e.to_string().contains(\"bun or npm is required\") => {\n        eprintln!(\"install bun (curl -fsSL https://bun.sh/install | bash) or Node.js\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Install bun or Node.js on every machine/CI image that runs the hub","Set PATH explicitly in systemd units, cron, and CI envs so ~/.bun/bin or nvm paths are visible","Prefer system-wide installs (or symlinks in /usr/local/bin) over shell-profile-only installs for daemon contexts","Add a dependency check (`which bun || which npm`) to your bootstrap script"],"tags":["rust","missing-dependency","bun","npm","path"],"backgroundTag":"missing-required-command","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}