Budibase/budibase · error

Must have yarn or npm installed to run build.

Error message

Must have yarn or npm installed to run build.

What it means

This is the terminal fallback in runPkgCommand: when the project provides no packageManager/lockfile signal (resolvePackageManager returns "auto"), the CLI tries npm then yarn; if neither binary is installed it cannot run any package script and throws this error.

Source

Thrown at packages/cli/src/exec.ts:113

      command === "install" ? `npm ${command}` : `npm run ${command}`
    await exec(npmCmd, dir)
    return
  }

  // Default to npm when the project has no lockfile/packageManager signal.
  if (npm) {
    const npmCmd =
      command === "install" ? `npm ${command}` : `npm run ${command}`
    await exec(npmCmd, dir)
    return
  }

  if (yarn) {
    await exec(`yarn ${command} --ignore-engines`, dir)
    return
  }

  throw new Error("Must have yarn or npm installed to run build.")
}

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Install Node.js (which bundles npm) from nodejs.org or via nvm, then verify `npm --version`
  2. Fix PATH in the execution environment (CI step, sudo secure_path, shell profile) so node/npm are found
  3. Add a lockfile or packageManager field so a specific manager is detected, and install that manager
  4. If using nvm, ensure `nvm use` runs in non-interactive shells (e.g. CI) before invoking budi

Example fix

// CI before
- run: budi plugins build   # no node/npm in image
// after
- uses: actions/setup-node@v4
  with: { node-version: 20 }
- run: budi plugins build
Defensive patterns

Strategy: validation

Validate before calling

const { execSync } = require("child_process")
function assertAnyPkgManager() {
  const ok = (cmd) => { try { execSync(cmd, { stdio: "ignore" }); return true } catch { return false } }
  if (!ok("npm --version") && !ok("yarn --version")) {
    throw new Error("Install Node.js (npm) or yarn before running budi plugin commands")
  }
}

Try / catch

try {
  await runPkgCommand("build", dir)
} catch (err) {
  if ((err as Error).message === "Must have yarn or npm installed to run build.") {
    console.error("No package manager on PATH; install Node.js first")
  }
  throw err
}

Prevention

When it happens

Trigger: Running budi plugin init/build/watch or the Svelte 5 migration in a plugin directory with no packageManager field and no lockfile, on a machine where both `npm --version` and `yarn --version` fail (Node.js not installed, or PATH not including the node bin directory).

Common situations: Fresh machines/containers without Node.js; running the CLI under sudo or systemd with a stripped PATH; broken nvm setup where the default node version isn't loaded in non-interactive shells.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/afde318bd11ffe4d. Report an issue: GitHub.