gatsbyjs/gatsby · error

10128

10128

Error message

It looks like you were trying to add the gatsby-node file? Please rename "${nearMatch}" to "${configName}.${isTSX ? `ts` : `js`}"

What it means

Thrown during Gatsby-file compilation when no exact `gatsby-node.ts`/`gatsby-node.js` is found but a near-match filename exists within edit distance 3 (isNearMatch). Gatsby assumes the user intended the canonical name and mistyped it (e.g. gatsby-nodees.js, gastby-node.ts). The panic includes the near match and suggests the correct name, choosing `.ts` over `.js` only when the typo ended in `.tsx`.

Source

Thrown at packages/gatsby/src/utils/parcel/compile-gatsby-files.ts:122

      // Of course, allow valid gatsby-node files
      if (
        file === `gatsby-node.js` ||
        file === `gatsby-node.mjs` ||
        file === `gatsby-node.ts`
      ) {
        break
      }

      // Check for likely misnamed files
      if (isNearMatch(name, gatsbyNodeName, 3)) {
        nearMatch = file
      }
    }

    // gatsby-node is misnamed
    if (nearMatch) {
      const isTSX = nearMatch.endsWith(`.tsx`)
      reporter.panic({
        id: `10128`,
        context: {
          configName: gatsbyNodeName,
          nearMatch,
          isTSX,
        },
      })
    }

    const worker = new WorkerPool<typeof import("./compile-gatsby-files")>(
      require.resolve(`./compile-gatsby-files`),
      {
        numWorkers: 1,
      }
    )

    const distDir = `${siteRoot}/${COMPILED_CACHE_DIR}`
    await ensureDir(distDir)

View on GitHub (pinned to 8b06340921)

Solutions

  1. Rename the suggested `nearMatch` file to exactly `gatsby-node.ts` (or `gatsby-node.js`).
  2. If the file is unrelated, rename it to something farther than distance 3 from `gatsby-node` so the heuristic no longer matches.
  3. Delete the stray near-match file if it was created by accident.

Example fix

// before (file in project root)
//   gastby-node.ts
// after
//   gatsby-node.ts
Defensive patterns

Strategy: validation

Validate before calling

// Scan the project root for near-matches before invoking the compiler.
const fs = require('fs')
const { isNearMatch } = require('./is-near-match') // or inline Levenshtein<=3
function findGatsbyNodeTypos(root) {
  const target = 'gatsby-node'
  const files = fs.readdirSync(root)
  const exact = files.some(f => /^gatsby-node\.(ts|js)$/.test(f))
  if (exact) return []
  return files.filter(f => isNearMatch(f.replace(/\.(t|j)sx?$/, ''), target, 3))
}

Type guard

function hasExactGatsbyNode(files) {
  return files.some(f => /^gatsby-node\.(ts|js)$/.test(f))
}

Prevention

When it happens

Trigger: Project root or a plugin dir contains a file like `gatsb-node.ts`, `gatsby-node.jsx`, `gatsbuy-node.js`, or similar within Levenshtein distance 3 of `gatsby-node`, and no exact `gatsby-node.{ts,js}` is present. The compile-gatsby-files scan sets `nearMatch` and panics instead of silently ignoring it.

Common situations: Renaming a file and making a typo; importing a starter that had a typo'd filename; legacy `.jsx`/`.tsx` confusion where the user wrote gatsby-node.tsx (suggested as .ts); copying gatsby-node from a tutorial and dropping a character.

Related errors


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