{"record":{"id":"33eb699c461e2aae","repo":"nikivdev/code","slug":"bun-or-npm-is-required-to-run-docs-hub-dev-server","errorCode":null,"errorMessage":"bun or npm is required to run docs hub dev server","messagePattern":"bun or npm is required to run docs hub dev server","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/docs.rs","lineNumber":579,"sourceCode":"            &host_arg,\n        ]);\n        cmd\n    } else if which(\"npm\").is_ok() {\n        let port_arg = port.to_string();\n        let host_arg = host.to_string();\n        let mut cmd = Command::new(\"npm\");\n        cmd.args([\n            \"run\",\n            \"dev\",\n            \"--\",\n            \"--port\",\n            &port_arg,\n            \"--hostname\",\n            &host_arg,\n        ]);\n        cmd\n    } else {\n        bail!(\"bun or npm is required to run docs hub dev server\");\n    };\n\n    let mut child = cmd\n        .current_dir(hub_root)\n        .stdout(std::process::Stdio::inherit())\n        .stderr(std::process::Stdio::inherit())\n        .spawn()\n        .context(\"failed to start docs hub dev server\")?;\n\n    if !no_open {\n        let url = format!(\"http://{}:{}\", host, port);\n        wait_for_port(host, port, std::time::Duration::from_secs(10));\n        open_in_browser(&url);\n    }\n\n    let status = child.wait().context(\"failed to wait on docs hub\")?;\n    if !status.success() {\n        bail!(\"docs hub dev server exited with error\");","sourceCodeStart":561,"sourceCodeEnd":597,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/docs.rs#L561-L597","documentation":"run_docs_hub_dev bails when neither bun nor npm is available to launch the docs hub dev server (Next.js-style `dev` command). The function must spawn the server via bun or npm; with neither on PATH it cannot start the process and returns this error.","triggerScenarios":"Calling run_docs_hub with dev-server options on a host where `which(\"bun\")` and `which(\"npm\")` both fail — no JavaScript runtime installed, or PATH does not include the user's node/bun installation.","commonSituations":"Server without Node tooling; tool spawned from systemd/cron/GUI with minimal PATH; nvm not initialized in non-login shells; recently switched machines without reinstalling bun.","solutions":["Install bun or npm and put it on PATH before running the hub dev command","Set PATH in the launching environment (systemd Environment=, cron PATH=, wrapper script)","If using nvm/fnm/volta, initialize it in the profile that launches the tool, or symlink the binaries to /usr/local/bin","Confirm availability: `which bun || which npm`"],"exampleFix":"// before\n$ mytool docs hub dev\nError: bun or npm is required to run docs hub dev server\n// after\n$ export PATH=\"$HOME/.bun/bin:$PATH\"\n$ mytool docs hub dev\nready on http://127.0.0.1:4410","handlingStrategy":"validation","validationCode":"let has_runner = which::which(\"bun\").is_ok() || which::which(\"npm\").is_ok();\nif !has_runner {\n    eprintln!(\"dev server needs bun or npm on PATH; install one first\");\n    return;\n}\nrun_docs_hub(&opts)?;","typeGuard":null,"tryCatchPattern":"match run_docs_hub(&opts) {\n    Err(e) if e.to_string().contains(\"required to run docs hub dev server\") => {\n        eprintln!(\"install bun or npm and re-run; check PATH for daemon launches\");\n    }\n    Err(e) => return Err(e),\n    Ok(()) => {}\n}","preventionTips":["Ensure non-interactive shells (cron, systemd, GUI launchers) include node/bun in PATH","Initialize nvm/fnm in profiles used by automation, or symlink binaries to /usr/local/bin","Keep one canonical JS runtime installed to reduce PATH drift","Verify `which bun || which npm` before scripting hub dev launches"],"tags":["rust","missing-dependency","dev-server","bun","npm"],"backgroundTag":"missing-required-command","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}