{"record":{"id":"0ca68097fa288b82","repo":"gatsbyjs/gatsby","slug":"package-manager-must-be-yarn-or-npm","errorCode":null,"errorMessage":"Package manager must be yarn or npm.","messagePattern":"Package manager must be yarn or npm\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby-cli/src/create-cli.ts","lineNumber":591,"sourceCode":"            choices: [`pm`, `package-manager`],\n            type: `string`,\n            describe: `Set the package manager \\`gatsby new\\` is using.`,\n          })\n          .positional(`value`, {\n            choices: [`npm`, `yarn`],\n            type: `string`,\n            describe: `Set package manager as \\`npm\\` or \\`yarn\\`.`,\n          }),\n\n      handler: handlerP(({ cmd, key, value }: yargs.Arguments) => {\n        if (!getPackageManager()) {\n          setPackageManager(`npm`)\n        }\n\n        if (cmd === `set`) {\n          if (key === `pm` || key === `package-manager`) {\n            if (value && value !== `yarn` && value !== `npm`) {\n              report.panic(`Package manager must be yarn or npm.`)\n            }\n\n            if (value) {\n              // @ts-ignore\n              setPackageManager(value)\n\n              return\n            } else {\n              setPackageManager(`npm`)\n            }\n          } else {\n            reporter.warn(\n              `Please pass your desired config key and value. Currently you can only set your package manager using \\`pm\\`.`\n            )\n          }\n          return\n        }\n","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby-cli/src/create-cli.ts#L573-L609","documentation":"Thrown by the `gatsby options set` handler when setting the package manager (`pm` or `package-manager` key) to a value other than `yarn` or `npm`. Only those two package managers are supported by `gatsby new`, so any other value is rejected outright.","triggerScenarios":"Running `gatsby options set pm pnpm` (or any value besides `yarn`/`npm`) triggers the panic. The handler explicitly checks `value !== 'yarn' && value !== 'npm'`.","commonSituations":"User prefers pnpm but Gatsby's scaffolder only supports npm/yarn; typo in the value (`NPM`, `Yarn`, trailing whitespace); scripting the option with an unsupported pm.","solutions":["Use `npm` or `yarn` as the value: `gatsby options set pm npm`.","If you use pnpm for the rest of the project, still set Gatsby's option to npm or yarn and manage the install step manually.","Check for trailing whitespace or capitalization in the value."],"exampleFix":"# before\ngatsby options set pm pnpm\n\n# after\ngatsby options set pm npm","handlingStrategy":"validation","validationCode":"const ALLOWED_PM = new Set(['npm', 'yarn'])\nif (!ALLOWED_PM.has(String(value))) throw new Error('Package manager must be yarn or npm')","typeGuard":"const isSupportedPm = (v: unknown): v is 'npm' | 'yarn' => v === 'npm' || v === 'yarn'","tryCatchPattern":null,"preventionTips":["Only pass `npm` or `yarn` to `gatsby options set pm`.","Avoid trailing whitespace/capitalization in the value.","If you use pnpm elsewhere, still set gatsby's option to npm or yarn."],"tags":["cli","options","package-manager","validation"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}