{"record":{"id":"925b601233d6f85b","repo":"vercel/next.js","slug":"only-custom-servers-can-pass-webpack-turbo-o","errorCode":null,"errorMessage":"Only custom servers can pass `webpack`, `turbo`, or `turbopack`.","messagePattern":"Only custom servers can pass `webpack`, `turbo`, or `turbopack`\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/next.ts","lineNumber":639,"sourceCode":"    const selectTurbopack =\n      options &&\n      (options.turbo || options.turbopack || process.env.IS_TURBOPACK_TEST)\n    const selectWebpack =\n      options && (options.webpack || process.env.IS_WEBPACK_TEST)\n    // Rspack is selected through env/config side effects instead of a custom\n    // server option, so don't fall back to the default Turbopack auto mode.\n    const selectRspack = !!process.env.NEXT_RSPACK\n    if (selectTurbopack && selectWebpack && selectRspack) {\n      throw new Error('Pass either `webpack` or `turbopack`, not both.')\n    }\n    if (selectTurbopack) {\n      process.env.TURBOPACK ??= '1'\n    } else if (!selectWebpack && !selectRspack) {\n      process.env.TURBOPACK ??= 'auto'\n    }\n  } else {\n    if (options && (options.webpack || options.turbo || options.turbopack)) {\n      throw new Error(\n        'Only custom servers can pass `webpack`, `turbo`, or `turbopack`.'\n      )\n    }\n  }\n\n  // The package is used as a TypeScript plugin.\n  if (\n    options &&\n    'typescript' in options &&\n    'version' in (options as any).typescript\n  ) {\n    const pluginMod: typeof import('./next-typescript') =\n      require('./next-typescript') as typeof import('./next-typescript')\n    return pluginMod.createTSPlugin(\n      options as any\n    ) as unknown as NextWrapperServer\n  }\n","sourceCodeStart":621,"sourceCodeEnd":657,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/next.ts#L621-L657","documentation":"Thrown by createServer() when the server is NOT a custom server (options.customServer is falsy) yet the caller passed `webpack`, `turbo`, or `turbopack` options. These bundler-selection options are only meaningful for custom servers; the standard NextServer (next start/dev) selects the bundler via CLI flags instead.","triggerScenarios":"Calling `next({ customServer: false, turbopack: true })` or programmatically constructing NextServer with bundler keys while not running a custom server.","commonSituations":"Mistakenly passing bundler options to the default Next() factory expecting CLI-style usage; adapting a custom-server example into a standard setup without removing the bundler keys.","solutions":["Remove the `webpack`, `turbo`, and `turbopack` keys from the options object when not using a custom server.","If you need bundler selection in the standard server, use CLI flags (`next dev --turbopack`, `next dev --webpack`) instead.","Set `customServer: true` if you genuinely are running a custom server and need these options."],"exampleFix":"// before\nconst app = next({ dev, customServer: false, turbopack: true })\n// after\nconst app = next({ dev })","handlingStrategy":"validation","validationCode":"const opts = { dev, customServer: false }\nif ('webpack' in opts || 'turbo' in opts || 'turbopack' in opts) {\n  throw new Error('Bundler options require customServer: true')\n}\nconst app = next(opts)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Don't pass webpack/turbo/turbopack to the standard NextServer (non-custom-server).","Use CLI flags (--turbopack/--webpack) for bundler selection in the standard server.","Set customServer: true only when you genuinely run a custom server."],"tags":["bundler","custom-server","config","turbopack","webpack"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}