{"record":{"id":"a7eb0d0440d56dc0","repo":"gatsbyjs/gatsby","slug":"there-was-a-problem-loading-the-local-command-c-a7eb0d","errorCode":null,"errorMessage":"There was a problem loading the local ${command} command. Gatsby may not be installed. Perhaps you need to run \"npm install\"?","messagePattern":"There was a problem loading the local (.+?) command\\. Gatsby may not be installed\\. Perhaps you need to run \"npm install\"\\?","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby-cli/src/create-cli.ts","lineNumber":95,"sourceCode":"        resolveCwd.silent(`gatsby/dist/utils/${command}`)\n      if (!cmdPath)\n        return report.panic(\n          `There was a problem loading the local ${command} command. Gatsby may not be installed in your site's \"node_modules\" directory. Perhaps you need to run \"npm install\"? You might need to delete your \"package-lock.json\" as well.`\n        )\n\n      report.verbose(`loading local command from: ${cmdPath}`)\n\n      const cmd = require(cmdPath)\n      if (cmd instanceof Function) {\n        return cmd\n      }\n\n      return report.panic(\n        `Handler for command \"${command}\" is not a function. Your Gatsby package might be corrupted, try reinstalling it and running the command again.`\n      )\n    } catch (err) {\n      cli.showHelp()\n      return report.panic(\n        `There was a problem loading the local ${command} command. Gatsby may not be installed. Perhaps you need to run \"npm install\"?`,\n        err\n      )\n    }\n  }\n\n  function getCommandHandler(\n    command: string,\n    handler?: (\n      args: yargs.Arguments,\n      cmd: (args: yargs.Arguments) => void\n    ) => void,\n    nodeEnv?: string | undefined\n  ): (argv: yargs.Arguments) => void {\n    return (argv: yargs.Arguments): void => {\n      report.setVerbose(!!argv.verbose)\n\n      report.setNoColor(!!(argv.noColor || process.env.NO_COLOR))","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby-cli/src/create-cli.ts#L77-L113","documentation":"Thrown from the `catch` block of `resolveLocalCommand`: `require(cmdPath)` threw an error while loading the command module. The command file exists but failed to execute (syntax error, missing transitive dependency, runtime error at module scope). The original error is attached and surfaced via `report.panic`.","triggerScenarios":"Loading `node_modules/gatsby/dist/commands/<command>.js` raises an exception: a `SyntaxError` in the file, a missing dependency it requires, a runtime throw at module-eval time, or an ESM/CJS interop failure. The CLI wraps and re-throws as a panic.","commonSituations":"Partial/corrupted gatsby install (missing dist files referenced by the command); a dependency of the command module is missing or has an incompatible version; Node version incompatibility with the installed gatsby; transpilation artifacts missing after a interrupted build of gatsby itself.","solutions":["Read the attached `err` in the panic output to find the underlying cause (syntax error, missing module, etc.).","Reinstall gatsby and its dependencies: `rm -rf node_modules package-lock.json && npm install`.","Ensure your Node.js version satisfies the gatsby major's minimum (see error 191).","If a specific dependency is named in the cause, install/upgrade that package to a compatible version."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"try { require(cmdPath) } catch (e) { console.error('Command failed to load:', e); process.exit(1) }","typeGuard":null,"tryCatchPattern":"try {\n  const cmd = require(cmdPath)\n} catch (e) {\n  // surface underlying module error (missing dep, syntax error) instead of generic panic\n  reporter.error(`Failed to load ${cmdPath}`, e)\n}","preventionTips":["Read the attached underlying error to find the missing/failed module.","Keep Node on a version supported by your gatsby major.","Reinstall gatsby and its peer deps on persistent load failures."],"tags":["cli","command-loading","require-error","install","node-modules"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}