Budibase/budibase · error

yarn is required to run this project (yarn.lock or packageMa

Error message

yarn is required to run this project (yarn.lock or packageManager indicates yarn).

What it means

For projects detected as yarn-based (yarn.lock or packageManager "yarn@"), runPkgCommand prefers running via yarn (with --ignore-engines). If yarn is missing it falls back to npm, but if npm is also unavailable it has no way to run the command and throws this error naming yarn as the expected tool.

Source

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

    if (!npm) {
      throw new Error(
        "npm is required to run this project (package-lock.json or packageManager indicates npm)."
      )
    }
    const npmCmd =
      command === "install" ? `npm ${command}` : `npm run ${command}`
    await exec(npmCmd, dir)
    return
  }

  // If the project indicates yarn, use it (with npm fallback).
  if (preferred === "yarn") {
    if (yarn) {
      await exec(`yarn ${command} --ignore-engines`, dir)
      return
    }
    if (!npm) {
      throw new Error(
        "yarn is required to run this project (yarn.lock or packageManager indicates yarn)."
      )
    }
    const npmCmd =
      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) {

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Install yarn: `npm install -g yarn` or `corepack enable`
  2. If yarn isn't wanted, ensure npm is installed so the fallback works
  3. Fix PATH so node package managers are discoverable (`which npm`, `which yarn`)
  4. Remove yarn.lock / packageManager field to switch detection to an installed manager

Example fix

// before
$ budi plugins build   # yarn.lock present, no yarn/npm installed
// after
$ corepack enable && yarn --version && budi plugins build
Defensive patterns

Strategy: validation

Validate before calling

const { execSync } = require("child_process")
const fs = require("fs")
function assertPackageManagerAvailable(dir = ".") {
  const wantsYarn = fs.existsSync(dir + "/yarn.lock") ||
    (JSON.parse(fs.readFileSync(dir + "/package.json", "utf8")).packageManager || "").startsWith("yarn@")
  if (wantsYarn) {
    try { execSync("yarn --version", { stdio: "ignore" }) }
    catch { execSync("npm --version", { stdio: "ignore" }) } // npm fallback must exist
  }
}

Try / catch

try {
  await runPkgCommand("build", dir)
} catch (err) {
  if ((err as Error).message.startsWith("yarn is required")) {
    console.error("Install yarn (corepack enable) or npm so the fallback works")
  }
  throw err
}

Prevention

When it happens

Trigger: Running budi plugin commands in a directory with yarn.lock (or packageManager: "yarn@...") on a machine that has neither yarn nor npm on PATH — e.g. minimal CI containers, broken Node installs, or PATH issues under sudo.

Common situations: CI images with only a bare node runtime; macOS/Linux machines where Node was removed but yarn.lock left behind; running the CLI in an environment where PATH doesn't include node bin dirs.

Related errors


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