vercel/next.js · error

Only custom servers can pass `webpack`, `turbo`, or…

Error message

Only custom servers can pass `webpack`, `turbo`, or `turbopack`.

What it means

Guard in createServer: bundler-selection options (webpack, turbo, turbopack) were passed, but the server being created is not a custom server (Next.js itself invoked the factory with customServer falsy). Those options only make sense when a user wires up their own HTTP server, so passing them here is a usage error.

Solutions

  1. Only pass bundler options when using a custom server (dev: false custom setup).
Defensive patterns

Strategy: validation

When it happens

Trigger: Bundler options are passed from a non-custom-server context.

Common situations: Passing webpack/turbopack options when not using a custom server.


AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19). Data as JSON: /api/errors/925b601233d6f85b. Report an issue: GitHub.

Appendix: source

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

    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 &&
    'version' in (options as any).typescript
  ) {
    const pluginMod: typeof import('./next-typescript') =
      require('./next-typescript') as typeof import('./next-typescript')
    return pluginMod.createTSPlugin(
      options as any
    ) as unknown as NextWrapperServer
  }

View on GitHub (pinned to 0eb3775416)