{"record":{"id":"b78d71a2818577b3","repo":"pnpm/pnpm","slug":"allow-build-missing-package","errorCode":"ALLOW_BUILD_MISSING_PACKAGE","errorMessage":"The --allow-build flag is missing a package name. Please specify the package name(s) that are allowed to run installation scripts.","messagePattern":"The --allow-build flag is missing a package name\\. Please specify the package name\\(s\\) that are allowed to run installation scripts\\.","errorType":"exception","errorClass":"PnpmError","httpStatus":null,"severity":"error","filePath":"pnpm11/installing/commands/src/add.ts","lineNumber":283,"sourceCode":"      const { alias } = parseWantedDependency(param)\n      return alias === 'pnpm' || alias === '@pnpm/exe'\n    })) {\n      throw new PnpmError('GLOBAL_PNPM_INSTALL', 'Use the \"pnpm self-update\" command to install or update pnpm')\n    }\n    return handleGlobalAdd({\n      ...opts,\n      ...createGlobalPolicyCallbacks(opts),\n    }, params, commands ?? {})\n  }\n\n  const include = {\n    dependencies: opts.production !== false,\n    devDependencies: opts.dev !== false,\n    optionalDependencies: opts.optional !== false,\n  }\n  if (opts.allowBuild?.length) {\n    if (opts.argv.original.includes('--allow-build')) {\n      throw new PnpmError('ALLOW_BUILD_MISSING_PACKAGE', 'The --allow-build flag is missing a package name. Please specify the package name(s) that are allowed to run installation scripts.')\n    }\n    if (opts.allowBuilds) {\n      const disallowedBuilds = Object.entries(opts.allowBuilds)\n        .filter(([, value]) => value === false)\n        .map(([pkg]) => pkg)\n      const overlapDependencies = disallowedBuilds.filter((dep) => opts.allowBuild?.includes(dep))\n      if (overlapDependencies.length) {\n        throw new PnpmError('OVERRIDING_IGNORED_BUILT_DEPENDENCIES', `The following dependencies are ignored by the root project, but are allowed to be built by the current command: ${overlapDependencies.join(', ')}`, {\n          hint: 'If you are sure you want to allow those dependencies to run installation scripts, remove them from the allowBuilds list (or change their value to true).',\n        })\n      }\n    }\n    const allowBuilds: Record<string, boolean> = {}\n    for (const pkg of opts.allowBuild) {\n      allowBuilds[pkg] = true\n    }\n    if (opts.rootProjectManifestDir) {\n      opts.rootProjectManifest = opts.rootProjectManifest ?? {}","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/pnpm/pnpm/blob/5b11d3a15b9022a2109cb18ed96a5d652630371f/pnpm11/installing/commands/src/add.ts#L265-L301","documentation":"--allow-build names the packages whose install scripts may run; it is a list flag, not a boolean switch. The guard fires when a bare `--allow-build` (nothing after it) appears in the raw argv while the effective allowBuild list is non-empty because it came from settings, so the flag cannot be silently treated as a blanket approval.","triggerScenarios":"Running `pnpm add <pkg> --allow-build` with no package names after the flag while pnpm-workspace.yaml or config supplies a non-empty allowBuild list.","commonSituations":"Assuming --allow-build behaves like a boolean strict flag; shell completion inserting the flag without arguments; commands copied from docs that omitted the names.","solutions":["Name the packages: `pnpm add <pkg> --allow-build esbuild --allow-build sharp`","Or drop the flag and configure the allow list persistently in pnpm-workspace.yaml (onlyBuiltDependencies / allowBuilds entries)","Use `pnpm approve-builds` interactively after install to grant script permissions"],"exampleFix":"# before\npnpm add foo --allow-build\n\n# after\npnpm add foo --allow-build esbuild sharp","handlingStrategy":"validation","validationCode":"const raw = process.argv\nconst i = raw.indexOf('--allow-build')\nconst next = i !== -1 ? raw[i + 1] : undefined\nif (i !== -1 && (next == null || next.startsWith('-'))) {\n  console.error('--allow-build needs package names after it')\n  process.exit(1)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat --allow-build as a list flag, never a boolean","Maintain the allow list in pnpm-workspace.yaml rather than on the CLI","Use `pnpm approve-builds` for interactive approval"],"tags":["scripts","security","cli","add","arguments"],"backgroundTag":null,"analyzedSha":"5b11d3a15b9022a2109cb18ed96a5d652630371f","analyzedAt":"2026-08-16T13:18:59.198Z","schemaVersion":2},"datasetVersion":"2026-08-16T18:17:16.020Z"}