gatsbyjs/gatsby · error

This plugin file is using both CommonJS and ES6 module syste

Error message

This plugin file is using both CommonJS and ES6 module systems together which we don't support.
You'll need to edit the file to use just one or the other.

plugin: ${modulePath}.js

This didn't cause a problem in Gatsby v1 so you might want to review the migration doc for this:
https://gatsby.dev/no-mixed-modules
      

What it means

Error "This plugin file is using both CommonJS and ES6 module systems together which we don't support. You'll need to edit the file to use just one or the other. plugin: ${modulePath}.js This didn't cause a problem in Gatsby v1 so you might want to review the migration doc for this: https://gatsby.dev/no-mixed-modules " thrown in gatsbyjs/gatsby.

Source

Thrown at packages/gatsby/src/bootstrap/resolve-module-exports.ts:167

      // get foo from `module.exports.foo = bar`
      if (t.isMemberExpression(nodeLeft.object)) {
        const exp: t.MemberExpression = nodeLeft.object

        if (
          t.isIdentifier(exp.object) &&
          t.isIdentifier(exp.property) &&
          exp.object.name === `module` &&
          exp.property.name === `exports`
        ) {
          isCommonJS = true
          exportNames.push((nodeLeft.property as t.Identifier).name)
        }
      }
    },
  })

  if (isES6 && isCommonJS && process.env.NODE_ENV !== `test`) {
    report.panic(
      `This plugin file is using both CommonJS and ES6 module systems together which we don't support.
You'll need to edit the file to use just one or the other.

plugin: ${modulePath}.js

This didn't cause a problem in Gatsby v1 so you might want to review the migration doc for this:
https://gatsby.dev/no-mixed-modules
      `
    )
  }
  return exportNames
}

interface IResolveModuleExportsOptions {
  mode?: `analysis` | `import`
  resolver?: ModuleResolver
  rootDir?: string
}

View on GitHub (pinned to e85d62f177)

Solutions

  1. Rewrite the plugin file to use only ES modules (import/export) or only CommonJS (module.exports/require)
  2. See https://gatsby.dev/no-mixed-modules for the v1 to v2 migration notes
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/gatsby/src/bootstrap/resolve-module-exports.ts:167 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/08d7ec80548d2a73. Report an issue: GitHub.