gatsbyjs/gatsby · error
There was a problem loading the local ${command} command. Ga
Error message
There was a problem loading the local ${command} command. Gatsby may not be installed. Perhaps you need to run "npm install"? What it means
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`.
Source
Thrown at packages/gatsby-cli/src/create-cli.ts:95
resolveCwd.silent(`gatsby/dist/utils/${command}`)
if (!cmdPath)
return report.panic(
`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.`
)
report.verbose(`loading local command from: ${cmdPath}`)
const cmd = require(cmdPath)
if (cmd instanceof Function) {
return cmd
}
return report.panic(
`Handler for command "${command}" is not a function. Your Gatsby package might be corrupted, try reinstalling it and running the command again.`
)
} catch (err) {
cli.showHelp()
return report.panic(
`There was a problem loading the local ${command} command. Gatsby may not be installed. Perhaps you need to run "npm install"?`,
err
)
}
}
function getCommandHandler(
command: string,
handler?: (
args: yargs.Arguments,
cmd: (args: yargs.Arguments) => void
) => void,
nodeEnv?: string | undefined
): (argv: yargs.Arguments) => void {
return (argv: yargs.Arguments): void => {
report.setVerbose(!!argv.verbose)
report.setNoColor(!!(argv.noColor || process.env.NO_COLOR))View on GitHub (pinned to 8b06340921)
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.
Defensive patterns
Strategy: try-catch
Validate before calling
try { require(cmdPath) } catch (e) { console.error('Command failed to load:', e); process.exit(1) } Try / catch
try {
const cmd = require(cmdPath)
} catch (e) {
// surface underlying module error (missing dep, syntax error) instead of generic panic
reporter.error(`Failed to load ${cmdPath}`, e)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- There was a problem loading the local ${command} command. Ga
- Handler for command "${command}" is not a function. Your Gat
- Could not find "gatsby" in ${rootPath}. Perhaps it wasn't in
- Could not find a suitable version of gatsby-cli. Please repo
- Something went wrong when trying to add the plugins to the p
AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13).
Data as JSON: /api/errors/a7eb0d0440d56dc0.
Report an issue: GitHub.