Skip to content

Cypress configs are CommonJS under root "type": "module" and will fail to load #2224

Open

Description

@trillium

Found while verifying #2221. Not a regression from that PR — it's pre-existing and currently latent, since no CI job runs Cypress.

The problem

Root package.json declares "type": "module" (re-added in f42f6fc, the ESM test-suite migration). That makes Node treat every .js under the repo root as ESM — including cypress/plugins/index.js, which is still CommonJS (module.exports = (on, config) => {...}).

cypress/support/index.js is comments-only today, so it's currently harmless, but it's in the same trap the moment anyone adds code to it.

Verified on development with Node v24.14.0:

$ node -e "console.log(typeof require('./cypress/plugins/index.js'))"
object

require() returns an empty namespace object instead of the exported function, so anything that loads the plugins file the way Cypress does will get a non-function — the same failure #2221 fixes for github-actions/pr-instructions/.

Suggested fix

Pick one, all are one-liners:

The cypress/package.json route is the more durable one, since it protects future files added under cypress/ automatically.

Not affected — checked already

  • shared/roles.js and shared/authorizationUtils.js also contain module.exports, but they're guarded with if (typeof module !== "undefined" && module.exports) and import each other as ESM, so they load correctly either way.
  • backend/ has its own package.json with "type": "module".
  • client/ has no type field, so its CJS configs (postcss.config.js, tailwind.config.js, setupProxy.js) are fine.

The only real breakage in the root tree is the Cypress plugins file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions