vercel/next.js · error

Pass either `webpack` or `turbopack`, not both.

Error message

Pass either `webpack` or `turbopack`, not both.

What it means

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.

Source

Thrown at packages/next/src/server/next.ts:630

}

// This file is used for when users run `require('next')`
function createServer(
  options: NextServerOptions & NextBundlerOptions
): NextWrapperServer {
  // next sets customServer to false when calling this function, in that case we don't want to modify the environment variables
  const isCustomServer = options?.customServer ?? true
  if (isCustomServer) {
    const selectTurbopack =
      options &&
      (options.turbo || options.turbopack || process.env.IS_TURBOPACK_TEST)
    const selectWebpack =
      options && (options.webpack || process.env.IS_WEBPACK_TEST)
    // Rspack is selected through env/config side effects instead of a custom
    // server option, so don't fall back to the default Turbopack auto mode.
    const selectRspack = !!process.env.NEXT_RSPACK
    if (selectTurbopack && selectWebpack && selectRspack) {
      throw new Error('Pass either `webpack` or `turbopack`, not both.')
    }
    if (selectTurbopack) {
      process.env.TURBOPACK ??= '1'
    } else if (!selectWebpack && !selectRspack) {
      process.env.TURBOPACK ??= 'auto'
    }
  } else {
    if (options && (options.webpack || options.turbo || options.turbopack)) {
      throw new Error(
        'Only custom servers can pass `webpack`, `turbo`, or `turbopack`.'
      )
    }
  }

  // The package is used as a TypeScript plugin.
  if (
    options &&
    'typescript' in options &&

View on GitHub (pinned to 0ae8c72462)

Solutions

  1. Choose exactly one bundler: pass only `turbopack: true` OR only `webpack: true`, and unset NEXT_RSPACK.
  2. Remove conflicting IS_TURBOPACK_TEST / IS_WEBPACK_TEST environment variables from your shell/CI.
  3. If using rspack, clear the turbo/turbopack/webpack options and rely solely on NEXT_RSPACK.

Example fix

// before
const app = next({ dev, turbopack: true, webpack: true })
// after
const app = next({ dev, turbopack: true })
Defensive patterns

Strategy: validation

Validate before calling

const opts = { dev }
const bundlers = [opts.turbo, opts.turbopack, opts.webpack, process.env.IS_TURBOPACK_TEST, process.env.IS_WEBPACK_TEST, process.env.NEXT_RSPACK].filter(Boolean)
if (bundlers.length > 1) {
  throw new Error('Select only one bundler (turbopack | webpack | rspack).')
}
const app = next(opts)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06). Data as JSON: /api/errors/e9cf2cbf8236fba9. Report an issue: GitHub.