{"record":{"id":"29c9eb17ce6a53e0","repo":"gatsbyjs/gatsby","slug":"there-was-a-problem-loading-the-local-command-c","errorCode":null,"errorMessage":"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.","messagePattern":"There was a problem loading the local (.+?) 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\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby-cli/src/create-cli.ts","lineNumber":79,"sourceCode":"    command: string\n  ): ((...args: Array<unknown>) => void) | never {\n    if (!isLocalSite) {\n      cli.showHelp()\n      report.verbose(`current directory: ${directory}`)\n      return report.panic(\n        `gatsby <${command}> can only be run for a gatsby site.\\n` +\n          `Either the current working directory does not contain a valid package.json or ` +\n          `'gatsby' is not specified as a dependency`\n      )\n    }\n\n    try {\n      const cmdPath =\n        resolveCwd.silent(`gatsby/dist/commands/${command}`) ||\n        // Old location of commands\n        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","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby-cli/src/create-cli.ts#L61-L97","documentation":"Thrown when `resolveCwd.silent` cannot find `gatsby/dist/commands/<command>` (or the legacy `gatsby/dist/utils/<command>`). `isLocalSite` passed (gatsby is declared in `package.json`) but the package is not actually installed under `node_modules`, so the command module cannot be resolved.","triggerScenarios":"`package.json` declares gatsby but `node_modules/gatsby` is absent or incomplete (missing `dist/commands/<command>.js`). Typical after a clone without install, a failed/partial install, or a corrupted lockfile.","commonSituations":"Fresh clone where `npm install`/`yarn` was not run; switching package managers left a stale/incomplete `node_modules`; a lockfile conflict resolved incorrectly; a globally-installed gatsby being shadowed by a broken local one.","solutions":["Run `npm install` (or `yarn`) in the project root to install gatsby into `node_modules`.","If install still fails, delete the lockfile (`package-lock.json` / `yarn.lock`) and `node_modules`, then reinstall.","Verify `node_modules/gatsby/dist/commands/<command>.js` exists after install.","Ensure the gatsby version declared in `package.json` is resolvable from the registry."],"exampleFix":"# before: gatsby declared but not installed\ngatsby develop  # -> error\n\n# after\nrm -rf node_modules package-lock.json\nnpm install\ngatsby develop","handlingStrategy":"validation","validationCode":"// Verify gatsby is installed under node_modules before invoking\nconst fs = require('fs'); const path = require('path')\nconst cmdFile = path.join('node_modules', 'gatsby', 'dist', 'commands', `${command}.js`)\nif (!fs.existsSync(cmdFile)) throw new Error('Run npm install first')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `npm install`/`yarn` after every fresh clone.","Commit a working lockfile and use the same package manager.","Delete lockfile + node_modules and reinstall on persistent failures."],"tags":["cli","install","node-modules","lockfile","bootstrap"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}