cypress-io/cypress · error · Error

Failed to load "next/dist/build/load-jsconfig" with error: $

Error message

Failed to load "next/dist/build/load-jsconfig" with error: ${ e.message ?? e}

What it means

Thrown by the Next.js handler when require.resolve('next/dist/build/load-jsconfig', resolvePaths) fails. nextLoadJsConfig is the helper Next uses to apply jsconfig.json path aliases and base url resolution; Cypress imports it so the same module resolution rules apply inside component tests. Unlike next/dist/build/utils (which has a fallback for pre-Next-13), load-jsconfig has no fallback path — any resolve failure becomes this error.

Source

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

    packages.loadConfig = require(loadConfigPath).default
  } catch (e: any) {
    throw new Error(`Failed to load "next/dist/server/config" with error: ${e.message ?? e}`)
  }

  try {
    const getNextJsBaseWebpackConfigPath = require.resolve('next/dist/build/webpack-config', resolvePaths)

    packages.getNextJsBaseWebpackConfig = require(getNextJsBaseWebpackConfigPath).default
  } catch (e: any) {
    throw new Error(`Failed to load "next/dist/build/webpack-config" with error: ${ e.message ?? e}`)
  }

  try {
    const loadJsConfigPath = require.resolve('next/dist/build/load-jsconfig', resolvePaths)

    packages.nextLoadJsConfig = require(loadJsConfigPath).default
  } catch (e: any) {
    throw new Error(`Failed to load "next/dist/build/load-jsconfig" with error: ${ e.message ?? e}`)
  }

  // Does not exist prior to Next 13.
  try {
    const getUtilsPath = require.resolve('next/dist/build/utils', resolvePaths)

    packages.getSupportedBrowsers = require(getUtilsPath).getSupportedBrowsers ?? (() => Promise.resolve([]))
  } catch (e: any) {
    throw new Error(`Failed to load "next/dist/build/utils" with error: ${ e.message ?? e}`)
  }

  return packages
}

/**
 * Types for `getNextJsBaseWebpackConfig` based on version:
 * - v14.0.0, v15.0.0, and v16.0.0
  [

View on GitHub (pinned to 0d85fdc912)

Solutions

  1. Upgrade Next.js to a version Cypress supports (>= 13).
  2. Reinstall node_modules to restore the missing file.
  3. If you must stay on Next 12, downgrade @cypress/webpack-dev-server to a version that has a fallback for load-jsconfig.
  4. Verify resolution: `node -e "console.log(require.resolve('next/dist/build/load-jsconfig'))"`.

Example fix

// before
"next": "^12.3.0"
// after
"next": "^14.2.0"
Defensive patterns

Strategy: validation

Validate before calling

function assertLoadJsConfig (resolvePaths: string[]) {
  try {
    require.resolve('next/dist/build/load-jsconfig', { paths: resolvePaths })
  } catch {
    throw new Error('Next.js < 13 detected; upgrade Next to enable Cypress CT load-jsconfig')
  }
}

Type guard

function supportsNextLoadJsConfig (resolvePaths: string[]): boolean {
  try { require.resolve('next/dist/build/load-jsconfig', { paths: resolvePaths }); return true }
  catch { return false }
}

Prevention

When it happens

Trigger: Using a Next.js version older than 13 where load-jsconfig did not exist, or a custom Next.js fork / alias that omits the file. Also triggered by broken installs where the file is missing from dist/build.

Common situations: Legacy Next.js 12 project upgraded Cypress without upgrading Next, broken node_modules, or `next` resolved to a non-standard distribution (e.g. a private fork).

Related errors


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