cypress-io/cypress · error · Error

Cypress cannot compile your Next.js application when "nodeVe

Error message

Cypress cannot compile your Next.js application when "nodeVersion" is set to "bundled". Please remove this option from your Cypress configuration file.

What it means

Thrown by checkForSWCLoader when the user's webpackConfig contains a next-swc-loader rule AND the Cypress config has nodeVersion set to 'bundled'. SWC compilation requires the user's native Node because the SWC binary and bindings must match the runtime; the bundled Node in older Cypress (< 9.0.0) or an explicit nodeVersion: 'bundled' setting cannot load the SWC native bindings, so Cypress refuses to compile rather than emitting cryptic native-module errors.

Source

Thrown at npm/webpack-dev-server/src/helpers/nextHandler.ts:184

/**
 * Check if Next is using the SWC compiler. Compilation will fail if user has `nodeVersion: "bundled"` set
 * due to SWC certificate issues.
 */
function checkSWC (
  webpackConfig: Configuration,
  cypressConfig: Cypress.PluginConfigOptions,
) {
  const hasSWCLoader = webpackConfig.module?.rules?.some((rule) => {
    return typeof rule !== 'string' && rule.oneOf?.some(
      (oneOf) => (oneOf.use as any)?.loader === 'next-swc-loader',
    )
  })

  // "resolvedNodePath" is only set when using the user's Node.js, which is required to compile Next.js with SWC optimizations
  // If it is not set, they have either explicitly set "nodeVersion" to "bundled" or are are using Cypress < 9.0.0 where it was set to "bundled" by default
  // @ts-expect-error nodeVersion has been removed as of 13.0.0 however this plugin can be used with many versions of cypress
  if (hasSWCLoader && cypressConfig.nodeVersion === 'bundled') {
    throw new Error(`Cypress cannot compile your Next.js application when "nodeVersion" is set to "bundled". Please remove this option from your Cypress configuration file.`)
  }

  return false
}

const exists = async (file: string) => {
  try {
    await fs.promises.access(file, fs.constants.F_OK)

    return true
  } catch (_) {
    return false
  }
}

/**
 * Next allows the `pages` directory to be located at either
 * `${projectRoot}/pages` or `${projectRoot}/src/pages`.

View on GitHub (pinned to 0d85fdc912)

Solutions

  1. Remove the `nodeVersion: 'bundled'` line from your Cypress config (it is deprecated since 9.0.0).
  2. If you need an explicit nodeVersion, use the user's resolved Node (do not set the option, or set nodeVersion: null in older APIs).
  3. Upgrade Cypress to >= 9.0.0 if you are on an older version where bundled was the default.
  4. Confirm the resolved node binary matches the platform of the SWC native binding (`npx cypress info`).

Example fix

// before (cypress.config.ts)
export default defineConfig({
  e2e: { nodeVersion: 'bundled', setupNodeEvents() {} },
})
// after
export default defineConfig({
  e2e: { setupNodeEvents() {} },
})
Defensive patterns

Strategy: validation

Validate before calling

import { readFileSync } from 'fs'

function hasBundledNodeVersion (configPath: string): boolean {
  const src = readFileSync(configPath, 'utf8')
  return /nodeVersion\s*:\s*['"]bundled['"]/.test(src)
}

if (hasBundledNodeVersion('./cypress.config.ts')) {
  console.warn('Remove nodeVersion: "bundled" — it breaks Next.js SWC compilation.')
}

Type guard

function isBundledNodeVersion (cfg: any): boolean {
  return cfg?.nodeVersion === 'bundled'
}

Prevention

When it happens

Trigger: A Next.js project using SWC (default since Next 12) where the user explicitly set `nodeVersion: 'bundled'` in cypress.config.ts/jonfig.js, or a Cypress < 9.0.0 install where bundled was the default. The check walks webpackConfig.module.rules looking for any oneOf whose use.loader === 'next-swc-loader'.

Common situations: Upgrading from Cypress 8 to a newer Cypress and copying over old config that still sets nodeVersion: 'bundled'; using a Next.js app with default SWC and not realizing bundled Node cannot load SWC bindings.

Related errors


AI-assisted analysis of cypress-io/cypress@0d85fdc912 (2026-08-12). Data as JSON: /api/errors/b7ad1868f896bff5. Report an issue: GitHub.