{"record":{"id":"e9cf2cbf8236fba9","repo":"vercel/next.js","slug":"pass-either-webpack-or-turbopack-not-both","errorCode":null,"errorMessage":"Pass either `webpack` or `turbopack`, not both.","messagePattern":"Pass either `webpack` or `turbopack`, not both\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/next.ts","lineNumber":630,"sourceCode":"}\n\n// This file is used for when users run `require('next')`\nfunction createServer(\n  options: NextServerOptions & NextBundlerOptions\n): NextWrapperServer {\n  // next sets customServer to false when calling this function, in that case we don't want to modify the environment variables\n  const isCustomServer = options?.customServer ?? true\n  if (isCustomServer) {\n    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 &&","sourceCodeStart":612,"sourceCodeEnd":648,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/next.ts#L612-L648","documentation":"Thrown by createServer() when constructing a custom server and the bundler selection is contradictory. The guard fires when turbopack (options.turbo/turbopack or IS_TURBOPACK_TEST), webpack (options.webpack or IS_WEBPACK_TEST), and rspack (NEXT_RSPACK env) are all simultaneously selected, since only one bundler can be active.","triggerScenarios":"A custom server (customServer option defaulting true) that passes both `webpack: true` and `turbo: true`/`turbopack: true`, while NEXT_RSPACK is also set; or conflicting IS_TURBOPACK_TEST and IS_WEBPACK_TEST env vars combined with NEXT_RSPACK.","commonSituations":"Copy-pasted custom server code that sets both bundler flags; CI environment leaking both IS_TURBOPACK_TEST and IS_WEBPACK_TEST plus NEXT_RSPACK; migrating between bundlers and forgetting to remove the old flag.","solutions":["Choose exactly one bundler: pass only `turbopack: true` OR only `webpack: true`, and unset NEXT_RSPACK.","Remove conflicting IS_TURBOPACK_TEST / IS_WEBPACK_TEST environment variables from your shell/CI.","If using rspack, clear the turbo/turbopack/webpack options and rely solely on NEXT_RSPACK."],"exampleFix":"// before\nconst app = next({ dev, turbopack: true, webpack: true })\n// after\nconst app = next({ dev, turbopack: true })","handlingStrategy":"validation","validationCode":"const opts = { dev }\nconst bundlers = [opts.turbo, opts.turbopack, opts.webpack, process.env.IS_TURBOPACK_TEST, process.env.IS_WEBPACK_TEST, process.env.NEXT_RSPACK].filter(Boolean)\nif (bundlers.length > 1) {\n  throw new Error('Select only one bundler (turbopack | webpack | rspack).')\n}\nconst app = next(opts)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set only one bundler selector at a time (turbopack XOR webpack XOR rspack).","Clear stale IS_TURBOPACK_TEST/IS_WEBPACK_TEST env vars from your shell.","When migrating bundlers, remove the old option/env before adding the new one.","Keep custom-server bundler options in one place to avoid conflicting duplicates."],"tags":["bundler","turbopack","webpack","rspack","custom-server","config"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}