gatsbyjs/gatsby · error

[gatsby-plugin-image] Couldn't find image data cache file

Error message

[gatsby-plugin-image] Couldn't find image data cache file

What it means

StaticImage babel-plugin warning: no cached image-data JSON exists for the computed options hash — the image was never processed by writeImages during the node phase of the build, so there is nothing to inline at compile time.

Solutions

  1. Ensure the image file exists and StaticImage src is a static string
  2. Rebuild from a clean cache (`gatsby clean`)
  3. Ensure Gatsby is at least 2.24.78 and gatsby-plugin-image is configured
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/gatsby-plugin-image/src/babel-plugin-parse-static-images.ts:61 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of gatsbyjs/gatsby@e85d62f177 (2026-08-26). Data as JSON: /api/errors/89a4b8b85f4bb360. Report an issue: GitHub.

Appendix: source

Thrown at packages/gatsby-plugin-image/src/babel-plugin-parse-static-images.ts:61

        if (unresolvedProps.length) {
          // TODO: Add a shortlink to docs on the plugin
          error = `Could not find values for the following props at build time: ${unresolvedProps.join(
            `, `
          )}`
          console.warn(`[gatsby-plugin-image] ${error}`)
        }

        // Adding the filename to the hashing, like in "extractStaticImageProps" function
        if (state.filename) {
          props.filename = slash(state.filename)
        }
        const hash = hashOptions(props)

        const cacheDir = (this.opts as Record<string, string>)?.cacheDir

        if (!cacheDir) {
          console.warn(
            `[gatsby-plugin-image] Couldn't find image data cache file`
          )
        }

        const filename = path.join(cacheDir, `${hash}.json`)
        let data: Record<string, unknown> | undefined

        // If there's no src prop there's no point in checking if it exists
        if (!unresolvedProps.includes(`src`)) {
          try {
            data = fs.readJSONSync(filename)
          } catch (e) {
            // TODO add info about minimum Gatsby version once this is merged
            const msg = stripIndent`
            Could not read image data file "${filename}". 
            This may mean that the images in "${this.filename}" were not processed.
            Please ensure that your gatsby version is at least 2.24.78.`
            error += msg

View on GitHub (pinned to e85d62f177)