gatsbyjs/gatsby · error

Could not create node for image ${src}

Error message

Could not create node for image ${src}

What it means

Guard in gatsby-plugin-image's node API: after resolving the file (and possibly creating a file node via gatsby-source-filesystem's createFileNode), `file` is still falsy, so the image cannot be processed and is skipped with a warning.

Source

Thrown at packages/gatsby-plugin-image/src/node-apis/image-processing.ts:145

          reporter.warn(
            `Could not find image "${src}" in "${filename}". Looked for ${fullPath}.`
          )
          return
        }

        try {
          const {
            createFileNode,
          } = require(`gatsby-source-filesystem/create-file-node`)

          file = await createFileNode(fullPath, createNodeId, {})
        } catch (e) {
          reporter.panic(`Please install gatsby-source-filesystem`)
        }
      }

      if (!file) {
        reporter.warn(`Could not create node for image ${src}`)
        return
      }

      // We need our own type, because `File` belongs to the filesystem plugin
      file.internal.type = `StaticImage`
      delete (file.internal as any).owner
      createNode(file)

      const cacheKey = `ref-${file.id}`

      // This is a cache of file node to static image mappings
      const imageRefs: Map<string, IImageMetadata> =
        (await cache.get(cacheKey)) || {}

      // Different cache: this is the one with the image properties
      const cacheFilename = path.join(cacheDir, `${hash}.json`)
      imageRefs[hash] = {
        contentDigest: file.internal?.contentDigest,

View on GitHub (pinned to e85d62f177)

Solutions

  1. Check the file is readable and a valid image
  2. Ensure gatsby-source-filesystem is installed
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/gatsby-plugin-image/src/node-apis/image-processing.ts:145 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/15cc6f96b8de6e98. Report an issue: GitHub.