gatsbyjs/gatsby · error

createNode must be a function, was ${typeof createNode}

Error message

createNode must be a function, was ${typeof createNode}

What it means

The gatsby-source-wordpress createRemoteFileNode copy validates that createNode is a function. It fires after the createNodeId check and before the cache check. Without a valid createNode, downloaded media would never enter the Gatsby node graph.

Source

Thrown at packages/gatsby-source-wordpress/src/steps/source-nodes/create-nodes/create-remote-file-node/index.js:411

  // if the url isn't already encoded
  // so decoding it doesn't do anything
  if (decodeURI(url) === url) {
    // encode the uri
    // this accounts for special characters in filenames
    url = encodeURI(url)
  }

  // validation of the input
  // without this it's notoriously easy to pass in the wrong `createNodeId`
  // see gatsbyjs/gatsby#6643
  if (typeof createNodeId !== `function`) {
    throw new Error(
      `createNodeId must be a function, was ${typeof createNodeId}`
    )
  }
  if (typeof createNode !== `function`) {
    throw new Error(`createNode must be a function, was ${typeof createNode}`)
  }
  if (typeof getCache === `function`) {
    // use cache of this plugin and not cache of function caller
    cache = getCache(`gatsby-source-filesystem`)
  }
  if (typeof cache !== `object`) {
    throw new Error(
      `Neither "cache" or "getCache" was passed. getCache must be function that return Gatsby cache, "cache" must be the Gatsby cache, was ${typeof cache}`
    )
  }

  // Check if we already requested node for this remote file
  // and return stored promise if we did.
  if (processingCache[url]) {
    return processingCache[url]
  }

  if (!url || isWebUri(url) === undefined) {

View on GitHub (pinned to 8b06340921)

Solutions

  1. Upgrade gatsby-source-wordpress to the latest release where internal createNode forwarding is intact.
  2. If forking, verify createNode is destructured from actions and passed to the createRemoteFileNode call.
  3. Confirm the Gatsby core version is within the supported range of gatsby-source-wordpress.
  4. Open an issue with the query/mutation that triggered the path so maintainers can reproduce.

Example fix

null
Defensive patterns

Strategy: validation

Validate before calling

if (typeof createNode !== 'function') { throw new TypeError('createNode not available in the WordPress media step') }

Type guard

const isCreateNode = (v) => typeof v === 'function'

Try / catch

null

Prevention

When it happens

Trigger: Internal plugin call missing createNode; helpers spread incorrectly so actions.createNode is not in scope; fork that lost the createNode forwarding.

Common situations: Bugs in a specific gatsby-source-wordpress version where the media-processing refactor dropped createNode from the call; incompatibility between gatsby-source-wordpress and a newer Gatsby core that renamed actions.

Related errors


AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13). Data as JSON: /api/errors/690ff5edc552c614. Report an issue: GitHub.