{"record":{"id":"409093ab5060a35f","repo":"cypress-io/cypress","slug":"failed-to-load-next-dist-build-utils-with-error","errorCode":null,"errorMessage":"Failed to load \"next/dist/build/utils\" with error: ${ e.message ?? e}","messagePattern":"Failed to load \"next/dist/build/utils\" with error: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"npm/webpack-dev-server/src/helpers/nextHandler.ts","lineNumber":82,"sourceCode":"  } catch (e: any) {\n    throw new Error(`Failed to load \"next/dist/build/webpack-config\" with error: ${ e.message ?? e}`)\n  }\n\n  try {\n    const loadJsConfigPath = require.resolve('next/dist/build/load-jsconfig', resolvePaths)\n\n    packages.nextLoadJsConfig = require(loadJsConfigPath).default\n  } catch (e: any) {\n    throw new Error(`Failed to load \"next/dist/build/load-jsconfig\" with error: ${ e.message ?? e}`)\n  }\n\n  // Does not exist prior to Next 13.\n  try {\n    const getUtilsPath = require.resolve('next/dist/build/utils', resolvePaths)\n\n    packages.getSupportedBrowsers = require(getUtilsPath).getSupportedBrowsers ?? (() => Promise.resolve([]))\n  } catch (e: any) {\n    throw new Error(`Failed to load \"next/dist/build/utils\" with error: ${ e.message ?? e}`)\n  }\n\n  return packages\n}\n\n/**\n * Types for `getNextJsBaseWebpackConfig` based on version:\n * - v14.0.0, v15.0.0, and v16.0.0\n  [\n    dir: string,\n    options:  {\n      buildId: string\n      encryptionKey: string\n      config: NextConfigComplete\n      compilerType: CompilerNameValues\n      dev?: boolean\n      entrypoints: webpack.EntryObject\n      isDevFallback?: boolean","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/cypress-io/cypress/blob/0d85fdc91230885bca0a91df278312800a48b727/npm/webpack-dev-server/src/helpers/nextHandler.ts#L64-L100","documentation":"Thrown when require.resolve('next/dist/build/utils', resolvePaths) fails. Cypress reads getSupportedBrowsers from this module to know which browsers Next targets during compilation; if the file is missing the handler has no list to work from. The inline comment 'Does not exist prior to Next 13' acknowledges the file is version-dependent, but the code does not provide a fallback at the require layer — it only falls back if getSupportedBrowsers is absent after a successful load.","triggerScenarios":"Using Next.js < 13 (where next/dist/build/utils either does not exist or has a different shape), or a broken/partial install where the file is missing in a modern Next version.","commonSituations":"Stale Next.js 12 install, manually trimmed node_modules, or a Next.js distribution that does not ship dist/build/utils.js.","solutions":["Upgrade to Next.js 13 or newer.","Reinstall node_modules to repair a partial Next.js install.","Confirm the file exists: `ls node_modules/next/dist/build/utils.js`.","If you must remain on Next 12, pin @cypress/webpack-dev-server to a version compatible with that Next line."],"exampleFix":"# verify\nls node_modules/next/dist/build/utils.js\n# repair\nrm -rf node_modules package-lock.json && npm install","handlingStrategy":"validation","validationCode":"function assertNextBuildUtils (resolvePaths: string[]) {\n  try {\n    require.resolve('next/dist/build/utils', { paths: resolvePaths })\n  } catch {\n    throw new Error('next/dist/build/utils missing — upgrade Next.js to >= 13')\n  }\n}","typeGuard":"function hasNextBuildUtils (resolvePaths: string[]): boolean {\n  try { require.resolve('next/dist/build/utils', { paths: resolvePaths }); return true }\n  catch { return false }\n}","tryCatchPattern":null,"preventionTips":["Use Next.js 13+ with current Cypress CT.","Reinstall node_modules if the file is unexpectedly missing.","Pin a Next version range that matches Cypress support."],"tags":["nextjs","dependency-resolution","dev-server","version-mismatch"],"backgroundTag":null,"analyzedSha":"0d85fdc91230885bca0a91df278312800a48b727","analyzedAt":"2026-08-12T16:24:28.056Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}