nikivdev/code · error · anyhow::Error
bun or npm is required to run docs hub dev server
Error message
bun or npm is required to run docs hub dev server
What it means
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.
Source
Thrown at src/docs.rs:579
&host_arg,
]);
cmd
} else if which("npm").is_ok() {
let port_arg = port.to_string();
let host_arg = host.to_string();
let mut cmd = Command::new("npm");
cmd.args([
"run",
"dev",
"--",
"--port",
&port_arg,
"--hostname",
&host_arg,
]);
cmd
} else {
bail!("bun or npm is required to run docs hub dev server");
};
let mut child = cmd
.current_dir(hub_root)
.stdout(std::process::Stdio::inherit())
.stderr(std::process::Stdio::inherit())
.spawn()
.context("failed to start docs hub dev server")?;
if !no_open {
let url = format!("http://{}:{}", host, port);
wait_for_port(host, port, std::time::Duration::from_secs(10));
open_in_browser(&url);
}
let status = child.wait().context("failed to wait on docs hub")?;
if !status.success() {
bail!("docs hub dev server exited with error");View on GitHub (pinned to a747e741ae)
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`
Example fix
// before $ mytool docs hub dev Error: bun or npm is required to run docs hub dev server // after $ export PATH="$HOME/.bun/bin:$PATH" $ mytool docs hub dev ready on http://127.0.0.1:4410
Defensive patterns
Strategy: validation
Validate before calling
let has_runner = which::which("bun").is_ok() || which::which("npm").is_ok();
if !has_runner {
eprintln!("dev server needs bun or npm on PATH; install one first");
return;
}
run_docs_hub(&opts)?; Try / catch
match run_docs_hub(&opts) {
Err(e) if e.to_string().contains("required to run docs hub dev server") => {
eprintln!("install bun or npm and re-run; check PATH for daemon launches");
}
Err(e) => return Err(e),
Ok(()) => {}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- bun or npm is required to install docs hub dependencies
- {} failed
- docs hub dev server exited with error
- bun, npx, or npm is required to run wrangler
- handled before project context load
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/33eb699c461e2aae.
Report an issue: GitHub.