{"record":{"id":"afde318bd11ffe4d","repo":"Budibase/budibase","slug":"must-have-yarn-or-npm-installed-to-run-build","errorCode":null,"errorMessage":"Must have yarn or npm installed to run build.","messagePattern":"Must have yarn or npm installed to run build\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/exec.ts","lineNumber":113,"sourceCode":"      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) {\n    await exec(`yarn ${command} --ignore-engines`, dir)\n    return\n  }\n\n  throw new Error(\"Must have yarn or npm installed to run build.\")\n}\n","sourceCodeStart":95,"sourceCodeEnd":115,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/cli/src/exec.ts#L95-L115","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Install Node.js (which bundles npm) from nodejs.org or via nvm, then verify `npm --version`","Fix PATH in the execution environment (CI step, sudo secure_path, shell profile) so node/npm are found","Add a lockfile or packageManager field so a specific manager is detected, and install that manager","If using nvm, ensure `nvm use` runs in non-interactive shells (e.g. CI) before invoking budi"],"exampleFix":"// CI before\n- run: budi plugins build   # no node/npm in image\n// after\n- uses: actions/setup-node@v4\n  with: { node-version: 20 }\n- run: budi plugins build","handlingStrategy":"validation","validationCode":"const { execSync } = require(\"child_process\")\nfunction assertAnyPkgManager() {\n  const ok = (cmd) => { try { execSync(cmd, { stdio: \"ignore\" }); return true } catch { return false } }\n  if (!ok(\"npm --version\") && !ok(\"yarn --version\")) {\n    throw new Error(\"Install Node.js (npm) or yarn before running budi plugin commands\")\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runPkgCommand(\"build\", dir)\n} catch (err) {\n  if ((err as Error).message === \"Must have yarn or npm installed to run build.\") {\n    console.error(\"No package manager on PATH; install Node.js first\")\n  }\n  throw err\n}","preventionTips":["Install Node.js before using the budi CLI","If using nvm, ensure it's loaded in non-interactive shells (CI, scripts)","Check `which node`/`which npm` when running under sudo or systemd","Add a tooling preflight step in CI images"],"tags":["cli","plugins","node","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"}