afterbuild/ops
ERR-746/Next.js 16 · Turbopack
ERR-746
TypeError: routesManifest.dataRoutes is not iterable · Module not found: Can't resolve 'some-cjs-only-package' · Turbopack could not parse /*! webpackChunkName */

appears when:After upgrading to Next.js 16 where Turbopack becomes the default bundler for both dev and build, breaking webpack loaders and CommonJS-only imports — or at server boot, when next start reads a routes-manifest.json a different build wrote

Turbopack build error in Next.js 16

Next 16 defaults to Turbopack. Webpack loaders no longer run, CommonJS-only packages need ESM wrappers, and custom webpack config is ignored. One error in this family is not a build failure at all: routesManifest.dataRoutes is not iterable throws at server boot, after a build that printed nothing wrong.

Last updated 8 August 2026 · 9 min read · By Hyder Shah
Direct answer
Turbopack build error in Next 16 is almost always an incompatible webpack loader, a CommonJS-only dependency, or an ignored webpack() function. Fix by configuring turbopack.rules and resolveAlias, replacing non-ESM deps, and using --webpack only as a temporary fallback. One failure in this family is not a build failure: TypeError: routesManifest.dataRoutes is not iterable throws at server boot, because next start read a routes-manifest.json a different build wrote — clear .next and rebuild with the same Next version that boots the server. Read node_modules/next/dist/docs/ before assuming old patterns work.

How do I fix Turbopack build error?

next.config.ts
typescript
01// next.config.ts — Next.js 16 config with Turbopack rules and webpack fallback path02import type { NextConfig } from "next";03 04const config: NextConfig = {05  // Turbopack is default in Next 16 — this block configures it06  turbopack: {07    rules: {08      // SVG as React component using the .svg?component suffix09      "*.svg?component": {10        loaders: ["@svgr/webpack"],11        as: "*.js",12      },13    },14    // module resolution aliases (replaces webpack config.resolve.alias)15    resolveAlias: {16      "@": "./src",17      "@lib": "./src/lib",18    },19  },20  // Optional: keep a legacy webpack config that only fires when you opt out21  // Run: next build --webpack to use the legacy path as a temporary fallback22};23 24export default config;25 26// Usage:27//   next dev           # Turbopack (default)28//   next build         # Turbopack (default)29//   next build --webpack   # legacy webpack fallback when a dep still breaks30//   import icon from "./hero.svg?component"; // renders as React component
Next 16 config — turbopack.rules replaces webpack loaders, resolveAlias replaces config.resolve.alias

Not a developer? We fix this for you at a fixed price: $299 emergency triage, done in 48 hours or fully refunded. Not sure what else is broken? Send the repo for the $49 audit.

What if the quick fix doesn't work?

01 · routesManifest.dataRoutes is not iterable — rebuild the manifest, then match the versions

routesManifest.dataRoutes is not iterable means the production server parsed .next/routes-manifest.json and found no dataRoutes key. In next@16.2.3 the read is unguarded — node_modules/next/dist/server/lib/router-utils/filesystem.js line 228 runs for (const route of routesManifest.dataRoutes) straight after JSON.parse, so a missing key throws instead of degrading. Every manifest next build writes carries it: node_modules/next/dist/build/generate-routes-manifest.js line 54 initialises dataRoutes: [], and node_modules/next/dist/build/index.js line 1560 only replaces that empty array when the app has Pages Router getServerSideProps or getStaticProps routes. An App-Router-only app is expected to ship "dataRoutes": [] — an empty array is iterable and is not the problem.

So the key is absent only when the file was not written by this version’s next build: a .next restored from a CI cache built on an older major, a runtime that installed a different next than the build step, a standalone output where the manifest was never copied next to server.js, or a truncated upload. Clearing .next and rebuilding fixes the first; only version parity fixes the rest.

scripts/diagnose-routes-manifest.sh
bash
01# 1. Confirm what the server is actually reading02node -e "const m=require('./.next/routes-manifest.json'); \03  console.log('version', m.version, '| dataRoutes', Array.isArray(m.dataRoutes) ? m.dataRoutes.length : m.dataRoutes)"04# Expected on next@16.x: version 3 | dataRoutes 0   (App Router only — empty is fine)05# Broken:                undefined  | dataRoutes undefined06 07# 2. Rebuild the manifest from scratch08rm -rf .next && npx next build09 10# 3. Match the binary that boots the server to the one that built11npx next --version          # run this on the SERVER, not your laptop12node -p "require('./package.json').dependencies.next"13 14# 4. standalone output — the manifest must travel with server.js15ls .next/standalone/.next/routes-manifest.json
Read the manifest before editing anything — step 1 tells you whether this is a stale artefact or a version mismatch

02 · Replace @svgr/webpack with build-time codegen

scripts/generate-svg-components.ts
typescript
01// scripts/generate-svg-components.ts — run at prebuild to emit .tsx from .svg02import { readFileSync, writeFileSync, readdirSync } from "fs";03import { join, parse } from "path";04import { transform } from "@svgr/core";05 06const srcDir = "src/assets/icons";07const outDir = "src/components/icons";08 09for (const file of readdirSync(srcDir).filter((f) => f.endsWith(".svg"))) {10  const svg = readFileSync(join(srcDir, file), "utf8");11  const name = parse(file).name.replace(/(^|-)(\w)/g, (_m, _d, c) => c.toUpperCase());12  const jsx = await transform(svg, { typescript: true, ref: true }, { componentName: name });13  writeFileSync(join(outDir, `${name}.tsx`), jsx);14}15 16// package.json17// "scripts": { "prebuild": "tsx scripts/generate-svg-components.ts" }
Committed .tsx files are bundler-agnostic. Works under Turbopack, webpack, Vite, or esbuild

03 · MDX with the native @next/mdx package

next.config.ts
typescript
01// next.config.ts — @next/mdx supports Turbopack natively in Next 1602import createMDX from "@next/mdx";03import type { NextConfig } from "next";04 05const withMDX = createMDX({06  extension: /\.mdx?$/,07  options: {08    remarkPlugins: [],09    rehypePlugins: [],10  },11});12 13const config: NextConfig = {14  pageExtensions: ["ts", "tsx", "md", "mdx"],15};16 17export default withMDX(config);
Replaces mdx-loader — @next/mdx is the first-party solution that works on both bundlers

04 · Dynamic require bridge for CommonJS-only dependencies

lib/legacy-cjs-dep.ts
typescript
01// lib/legacy-cjs-dep.ts — server-only wrapper for a stubborn CJS package02import { createRequire } from "node:module";03 04export function loadLegacy() {05  // Only call from server components or route handlers06  const require = createRequire(import.meta.url);07  const legacy = require("legacy-cjs-only-package");08  return legacy;09}
Use when a dep refuses to ship ESM. Never import from client components — server-only

Does this error survive a redeploy, or does it only reproduce locally?

Neither, reliably — and that is what makes it confusing. The corpus around this error is written from local reproduction, but the impressions land on a build-log symptom, so the two populations are describing different moments. A routes-manifest.json problem does not reproduce on a laptop that just ran next build and next start back to back against the same node_modules: that sequence guarantees version parity and a fresh manifest, which is exactly the state the error cannot occur in. It reproduces where the build step and the boot step are separated — a cached .next, a Docker layer, a standalone bundle, an artefact uploaded between two jobs. A redeploy clears it whenever the redeploy also rebuilds .next from a clean checkout, and leaves it in place whenever the platform restores a build cache instead.

If the manifest is regenerated but the error persists

Every competing page stops at “delete .next”. When that does not clear it, the second cause is that the next package resolving at boot is not the one that built the directory. Run npx next --version on the machine that starts the server rather than on the machine that built, and compare it to the next entry in package.json. Two configurations produce the mismatch quietly: a lockfile installed with a different resolution on the runtime image than in CI, and a distDir override that points next start at a directory some other build wrote. Both leave a perfectly valid manifest on disk — just not one this reader understands. If the versions match and the boot still throws, you can send us the failing build — the build log paired with the step-1 manifest read is enough to separate a stale artefact from a version mismatch without access to the repository.

Tried the fix and still broken?

Send your app URL. A senior engineer records a 10-minute teardown.

Free, and fully async — no call to book. A senior engineer walks your app on video: what’s broken, what’s risky, what to fix first. In your inbox within 24 hours. Want the code read line by line instead? Send the repo for the $49 audit.

Why do AI-built apps hit Turbopack build error?

Next.js 16 promoted Turbopack from an experimental dev server to the default bundler for both next dev and next build. Turbopack is written in Rust and shares very little code with webpack. It does not execute webpack loaders. It does not read your webpack() function in next.config.js. It has its own much smaller configuration surface under the turbopack key, and it prefers ESM packages over CommonJS. The compatibility gap is well-documented but invisible to code that was written before Next 16.

AI builders scaffold Next.js apps with boilerplate from 2023 and 2024: @svgr/webpack for SVG imports, mdx-loader for markdown, raw-loader for text files, a webpack() function that adds a resolve alias. All of these were standard. All of them are silently ignored or explicitly failing under Turbopack. Same source code, completely different build result.

CommonJS is the second pain point. A surprising number of packages still ship CommonJS only or ship an ESM wrapper with a broken package.json exports field. Turbopack follows Node's strict resolution rules, so if the package advertises ESM but the file is actually CommonJS, Turbopack fails to parse it. Webpack was permissive and would fall back to CommonJS. Turbopack does not. The fix is to install a patched version or wrap the import in a dynamic require.

Experimental flags from earlier Next.js versions also cause failures. Flags like serverActions.bodySizeLimit moved into stable config under different names, and some options were removed entirely. Read node_modules/next/dist/docs/ before shipping. The docs list every deprecated flag and its replacement. AI-generated code rarely cross-references deprecations because the training data predates the release.

Diagnose Turbopack build error by failure mode

Which Turbopack build failures are not this error? Manifest-shape failures and loader failures produce similar-looking red text at different moments in the pipeline, and only one of the four rows below is helped by falling back to --webpack. Read the moment the error appeared — build, or first request after boot — before choosing a fix.

Error textWhen it appearsWhat it actually isDoes --webpack help?
TypeError: routesManifest.dataRoutes is not iterableServer boot / first request, after a clean buildManifest shape. next start parsed a routes-manifest.json with no dataRoutes key, so it did not come from this version's next buildNo — the manifest reader is bundler-agnostic
Module not found: Can't resolve '<pkg>'During next buildResolution. A CommonJS-only dependency, or a package whose exports field advertises ESM it does not shipOften yes, as a temporary bridge
Turbopack could not parse /*! webpackChunkName */During next buildLoader. A webpack-only loader or magic comment that Turbopack does not executeYes — this is the case --webpack exists for
Could not find a production build in the '.next' directoryServer bootMissing artefact. distDir has no BUILD_ID — the build never ran, or ran into a different directoryNo — nothing was built to fall back to

Which AI builders ship Turbopack build error?

How often each AI builder ships this error and the pattern that produces it.

AI builder × Turbopack build error
BuilderFrequencyPattern
LovableEvery Next 16 scaffoldUses @svgr/webpack — silently ignored by Turbopack
Bolt.newCommonAdds custom webpack() function that Turbopack does not read
v0CommonPulls in CJS-only chart libraries that fail ESM resolution
CursorSometimesUses deprecated experimental flags from Next 14
Replit AgentRareMixes next dev (Turbopack) with next build --webpack — inconsistent output

How do I stop Turbopack build error recurring?

Still stuck with Turbopack build error?

Emergency triage · $299 · 48h turnaround
We restore service and write the root-cause report.
start the triage →

Turbopack build error questions

What does "TypeError: routesManifest.dataRoutes is not iterable" mean?+
It means the production server read a routes-manifest.json that has no dataRoutes key — so the process is not reading the manifest that this version of next build wrote. In next@16.2.3 the read is unguarded: node_modules/next/dist/server/lib/router-utils/filesystem.js line 228 runs `for (const route of routesManifest.dataRoutes)` after JSON.parse of .next/routes-manifest.json, and undefined is not iterable. Every manifest next build writes carries the key — generate-routes-manifest.js line 54 initialises dataRoutes to an empty array before anything else can populate it — so the missing key points at a stale, partial, or foreign .next directory, not at your source code.
Is routesManifest.dataRoutes is not iterable a Turbopack build error at all?+
No. The throw happens at server boot, not during the build. The block that reads the manifest in next@16.2.3 sits inside an `if (!opts.dev)` guard in server/lib/router-utils/filesystem.js, and that module is required by server/lib/start-server.js — the production router server that next start and the standalone server.js output both boot. next dev never reaches it, and the reader is bundler-agnostic, so switching to --webpack does not change the outcome. A build that printed no errors and a server that dies on the first request are consistent with each other here.
The manifest was regenerated and the error persists — what is the second cause?+
The next binary that starts the server is not the next binary that built the directory. Deleting .next and rebuilding fixes a stale manifest; it does not fix a runtime that installs a different Next major than the build did, a standalone output where .next/routes-manifest.json was never copied alongside server.js, or a distDir override that points next start at a directory a different build wrote. Compare the version in package.json against `npx next --version` on the machine that boots the server, and confirm .next/routes-manifest.json exists at the distDir the server actually resolves.
Why did Turbopack break after upgrading to Next.js 16?+
Next.js 16 makes Turbopack the default bundler for both dev and build. Turbopack is a Rust-based replacement for webpack that does not run webpack loaders, cannot resolve CommonJS-only packages the same way, and ignores most custom webpack config. Any third-party loader (like mdx-loader, raw-loader, file-loader) stops working. Dependencies with only CommonJS exports need an ESM adapter. Check your dependency list against the Turbopack compatibility matrix.
Can I still use custom webpack config with Turbopack?+
No. Turbopack ignores the webpack function in next.config.js entirely when turbopack is the active bundler. Instead you configure Turbopack with the turbopack key — which accepts rules for alias, moduleIdStrategy, and a much smaller set of options. If your webpack config added SVG-as-component support or aliased @/lib to src/lib, translate those rules to Turbopack equivalents. The webpack function is dead code in Next 16 with Turbopack on.
How do I fall back to webpack in Next.js 16?+
Pass `--webpack` to `next dev` and `next build`. This reverts to the legacy bundler. Use this only as a temporary bridge — Next.js 17 may remove webpack entirely and the performance gap favors Turbopack. The right long-term fix is to migrate each incompatible dependency to a Turbopack-friendly alternative rather than permanently running the legacy bundler.
What is the canonical SVG-as-React-component replacement for SVGR under Turbopack?+
Turbopack does not run @svgr/webpack. Two replacements exist: first, use next/image with an SVG file (works for static icons); second, install @svgr/core and transform at build time into real .tsx files, committed to git. A third option is to use heroicons or lucide-react and delete the SVG transforms entirely. AI-generated code often pulls in @svgr/webpack as a legacy pattern; in Next 16 remove it.
How long does a Turbopack migration take?+
A small app with no custom webpack config and all-ESM deps takes zero work — it just runs faster. A medium app with SVGR, MDX, and a couple of CommonJS packages is a four to eight hour migration. A complex monorepo with a custom webpack loader chain is a day or two. Our App Migration service runs full Next.js 16 and Turbopack audits and ships a green build with a CI test suite.
Next step

Ship the fix. Keep the fix.

Emergency Triage restores service in 48 hours. Break the Fix Loop rebuilds CI so this error cannot ship again.

About the author

Hyder Shah leads Afterbuild Labs, shipping production rescues for apps built in Lovable, Bolt.new, Cursor, Replit, v0, and Base44. our rescue methodology.

Sources