{"record":{"id":"876eadeed524c3bc","repo":"gatsbyjs/gatsby","slug":"gatsby-plugin-sharp-wasn-t-setup-correctly-in-gats","errorCode":null,"errorMessage":"Gatsby-plugin-sharp wasn't setup correctly in gatsby-config.js. Make sure you add it to the plugins array.","messagePattern":"Gatsby-plugin-sharp wasn't setup correctly in gatsby-config\\.js\\. Make sure you add it to the plugins array\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby-plugin-sharp/src/index.js","lineNumber":130,"sourceCode":"  const prefixedSrc =\n    (pathPrefix ? pathPrefix : ``) +\n    `/static/${digestDirPrefix}` +\n    encodedImgSrc\n\n  return {\n    src: prefixedSrc,\n    outputDir: outputDir,\n    relativePath: outputFilePath,\n    width,\n    height,\n    aspectRatio,\n    options: removeDefaultValues(args, getPluginOptions()),\n  }\n}\n\nfunction createJob(job, { reporter }) {\n  if (!actions) {\n    reporter.panic(\n      `Gatsby-plugin-sharp wasn't setup correctly in gatsby-config.js. Make sure you add it to the plugins array.`\n    )\n  }\n\n  // Jobs can be duplicates and usually are long running tasks.\n  // Because of that we shouldn't use async/await and instead opt to use\n  // .then() /.catch() handlers, because this allows V8 to release\n  // duplicate jobs from memory quickly (as job is not referenced\n  // in resolve / reject handlers). If we would use async/await\n  // entire closure would keep duplicate job in memory until\n  // initial job finish.\n  const promise = actions.createJobV2(job).catch(err => {\n    reporter.panic(`error converting image`, err)\n  })\n\n  return promise\n}\n","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby-plugin-sharp/src/index.js#L112-L148","documentation":"In gatsby-plugin-sharp's createJob function (index.js:128-133), a module-level 'actions' variable is expected to be populated (set during the plugin's setup lifecycle). If actions is still falsy/undefined when createJob is called, it means the plugin's setup hook did not run — typically because gatsby-plugin-sharp is not properly registered in the gatsby-config.js plugins array. reporter.panic fires with this message.","triggerScenarios":"Another plugin or user code calls into gatsby-plugin-sharp's queueImageResizing or generateImageData pipeline, but gatsby-plugin-sharp was never initialized because it is missing from gatsby-config.js plugins. The actions variable was never assigned via the plugin's onPreInit or createResolvers lifecycle.","commonSituations":"Using gatsby-transformer-sharp (which depends on gatsby-plugin-sharp) without listing gatsby-plugin-sharp in plugins. Plugin listed as a string dependency instead of in gatsby-config. Plugin installed but not added to the config after a refactor.","solutions":["Add gatsby-plugin-sharp to the plugins array in gatsby-config.js","Ensure it appears before plugins that depend on it (e.g. gatsby-transformer-sharp)","Run npm install gatsby-plugin-sharp if not yet installed","Restart the Gatsby development server after config changes"],"exampleFix":"// before (gatsby-config.js)\nplugins: [\n  `gatsby-transformer-sharp`,\n  // gatsby-plugin-sharp missing\n],\n\n// after\nplugins: [\n  `gatsby-plugin-sharp`,\n  `gatsby-transformer-sharp`,\n],","handlingStrategy":"validation","validationCode":"// Validate gatsby-config.js has gatsby-plugin-sharp before building\nconst config = require('./gatsby-config')\nconst hasSharp = config.plugins.some(p =>\n  typeof p === 'string' ? p === 'gatsby-plugin-sharp' : p.resolve === 'gatsby-plugin-sharp'\n)\nif (!hasSharp) {\n  throw new Error('gatsby-plugin-sharp must be in the plugins array')\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always list gatsby-plugin-sharp in gatsby-config.js plugins array","Place gatsby-plugin-sharp before gatsby-transformer-sharp in the plugins order","Run a config validation script before builds to catch missing plugins"],"tags":["configuration","missing-dependency","sharp","image-processing"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}