{"record":{"id":"356f986c64e89d74","repo":"Budibase/budibase","slug":"yarn-is-required-to-run-this-project-yarn-lock-or","errorCode":null,"errorMessage":"yarn is required to run this project (yarn.lock or packageManager indicates yarn).","messagePattern":"yarn is required to run this project \\(yarn\\.lock or packageManager indicates yarn\\)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/exec.ts","lineNumber":90,"sourceCode":"    if (!npm) {\n      throw new Error(\n        \"npm is required to run this project (package-lock.json or packageManager indicates npm).\"\n      )\n    }\n    const npmCmd =\n      command === \"install\" ? `npm ${command}` : `npm run ${command}`\n    await exec(npmCmd, dir)\n    return\n  }\n\n  // If the project indicates yarn, use it (with npm fallback).\n  if (preferred === \"yarn\") {\n    if (yarn) {\n      await exec(`yarn ${command} --ignore-engines`, dir)\n      return\n    }\n    if (!npm) {\n      throw new Error(\n        \"yarn is required to run this project (yarn.lock or packageManager indicates yarn).\"\n      )\n    }\n    const npmCmd =\n      command === \"install\" ? `npm ${command}` : `npm run ${command}`\n    await exec(npmCmd, dir)\n    return\n  }\n\n  // Default to npm when the project has no lockfile/packageManager signal.\n  if (npm) {\n    const npmCmd =\n      command === \"install\" ? `npm ${command}` : `npm run ${command}`\n    await exec(npmCmd, dir)\n    return\n  }\n\n  if (yarn) {","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/cli/src/exec.ts#L72-L108","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Install yarn: `npm install -g yarn` or `corepack enable`","If yarn isn't wanted, ensure npm is installed so the fallback works","Fix PATH so node package managers are discoverable (`which npm`, `which yarn`)","Remove yarn.lock / packageManager field to switch detection to an installed manager"],"exampleFix":"// before\n$ budi plugins build   # yarn.lock present, no yarn/npm installed\n// after\n$ corepack enable && yarn --version && budi plugins build","handlingStrategy":"validation","validationCode":"const { execSync } = require(\"child_process\")\nconst fs = require(\"fs\")\nfunction assertPackageManagerAvailable(dir = \".\") {\n  const wantsYarn = fs.existsSync(dir + \"/yarn.lock\") ||\n    (JSON.parse(fs.readFileSync(dir + \"/package.json\", \"utf8\")).packageManager || \"\").startsWith(\"yarn@\")\n  if (wantsYarn) {\n    try { execSync(\"yarn --version\", { stdio: \"ignore\" }) }\n    catch { execSync(\"npm --version\", { stdio: \"ignore\" }) } // npm fallback must exist\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runPkgCommand(\"build\", dir)\n} catch (err) {\n  if ((err as Error).message.startsWith(\"yarn is required\")) {\n    console.error(\"Install yarn (corepack enable) or npm so the fallback works\")\n  }\n  throw err\n}","preventionTips":["Enable corepack to get yarn automatically for yarn.lock projects","Ensure at least npm exists as a fallback wherever builds run","Verify PATH includes node bin dirs in CI/sudo contexts","Remove yarn.lock if the team standardized on another manager"],"tags":["cli","plugins","yarn","package-manager","environment"],"backgroundTag":"missing-package-manager","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}