nextjs - ✅(Solved) Fix Next.js 16 Turbopack error: invalid utf-8 sequence of 1 bytes from index 0 [1 pull requests, 2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#85110Fetched 2026-04-08 02:17:24
View on GitHub
Comments
2
Participants
3
Timeline
19
Reactions
7
Timeline (top)
subscribed ×11commented ×2referenced ×2cross-referenced ×1

Error Message

Error: Turbopack build failed with 3 errors: ./node_modules/.pnpm/@[email protected]/node_modules/@esbuild/darwin-arm64/README.md Unknown module type This module doesn't have an associated type. Use a known file extension, or register a loader for it.

Read more: https://nextjs.org/docs/app/api-reference/next-config-js/turbo#webpack-loaders

Import trace: App Route: ./node_modules/.pnpm/@[email protected]/node_modules/@esbuild/darwin-arm64/README.md ./node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js ./node_modules/.pnpm/esbuild-[email protected]_esbuild@0.25.11/node_modules/esbuild-register/dist/node.js ./node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/api.js ./node_modules/.pnpm/@[email protected]_@[email protected]_payload@[email protected]_typescript@[email protected]/node_modules/@payloadcms/drizzle/dist/postgres/requireDrizzleKit.js ./node_modules/.pnpm/@[email protected]_payload@[email protected]_typescript@5.7.3_/node_modules/@payloadcms/db-postgres/dist/index.js ./src/payload.config.ts ./src/app/(payload)/api/graphql-playground/route.ts

./node_modules/.pnpm/@[email protected]/node_modules/@esbuild/darwin-arm64/bin/esbuild Reading source code for parsing failed An unexpected error happened while trying to read the source code to parse: failed to convert rope into string

Caused by:

  • invalid utf-8 sequence of 1 bytes from index 0

Import traces: #1 [App Route]: ./node_modules/.pnpm/@[email protected]/node_modules/@esbuild/darwin-arm64/bin/esbuild ./node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js ./node_modules/.pnpm/esbuild-[email protected]_esbuild@0.25.11/node_modules/esbuild-register/dist/node.js ./node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/api.js ./node_modules/.pnpm/@[email protected]_@[email protected]_payload@[email protected]_typescript@[email protected]/node_modules/@payloadcms/drizzle/dist/postgres/requireDrizzleKit.js ./node_modules/.pnpm/@[email protected]_payload@[email protected]_typescript@5.7.3_/node_modules/@payloadcms/db-postgres/dist/index.js ./src/payload.config.ts ./src/app/(payload)/api/graphql-playground/route.ts

#2 [App Route]: ./node_modules/.pnpm/@[email protected]/node_modules/@esbuild/darwin-arm64/bin/esbuild ./node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js ./node_modules/.pnpm/esbuild-[email protected]_esbuild@0.25.11/node_modules/esbuild-register/dist/node.js ./node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/api.js ./node_modules/.pnpm/@[email protected]_@[email protected]_payload@[email protected]_typescript@[email protected]/node_modules/@payloadcms/drizzle/dist/postgres/requireDrizzleKit.js ./node_modules/.pnpm/@[email protected]_payload@[email protected]_typescript@5.7.3_/node_modules/@payloadcms/db-postgres/dist/index.js ./src/payload.config.ts ./src/app/(payload)/api/[...slug]/route.ts

#3 [Server Component]: ./node_modules/.pnpm/@[email protected]/node_modules/@esbuild/darwin-arm64/bin/esbuild ./node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js ./node_modules/.pnpm/esbuild-[email protected]_esbuild@0.25.11/node_modules/esbuild-register/dist/node.js ./node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/api.js ./node_modules/.pnpm/@[email protected]_@[email protected]_payload@[email protected]_typescript@[email protected]/node_modules/@payloadcms/drizzle/dist/postgres/requireDrizzleKit.js ./node_modules/.pnpm/@[email protected]_payload@[email protected]_typescript@5.7.3_/node_modules/@payloadcms/db-postgres/dist/index.js ./src/payload.config.ts ./src/app/(frontend)/page.tsx

Root Cause

Caused by:

  • invalid utf-8 sequence of 1 bytes from index 0

Fix Action

Fixed

PR fix notes

PR #14475: feat(next): turbopack build support, fix incorrect handling of external packages

Description (problem / solution / changelog)

Fixes https://github.com/payloadcms/payload/issues/14338 and https://github.com/vercel/next.js/issues/85110#issuecomment-3444212808.

This PR should fix support for using turbopack to build your Next.js project (which is now the default in Next.js 16, unless you pass next build --webpack).

Previously, we were directly externalizing dependencies like libsql as they cause an error when being bundled. However, as those dependencies were not installed at the top-level by the user, the resulting require('libsql') calls could fail in production.

Turbopack threw the following warning:

Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.\nTry to install it into the project directory by running

However, we ignored this warning, as we cannot force users to manually install dependencies of our dependencies.

In Next.js 16, when using Turbopack build, this is no longer a warning but an error, which is why attempting to use turbopack build right now will not work.

This PR properly fixes this externalization issue, by externalizing the entry points of those problematic packages (our db adapters). This means we no longer need to hide the warning.

Changed files

  • packages/next/src/withPayload.js (modified, +21/-63)
  • test/plugin-multi-tenant/e2e.spec.ts (modified, +10/-0)

Code Example

Error: Turbopack build failed with 3 errors:
./node_modules/.pnpm/@esbuild+darwin-arm64@0.25.11/node_modules/@esbuild/darwin-arm64/README.md
Unknown module type
This module doesn't have an associated type. Use a known file extension, or register a loader for it.

Read more: https://nextjs.org/docs/app/api-reference/next-config-js/turbo#webpack-loaders

Import trace:
  App Route:
    ./node_modules/.pnpm/@esbuild+darwin-arm64@0.25.11/node_modules/@esbuild/darwin-arm64/README.md
    ./node_modules/.pnpm/esbuild@0.25.11/node_modules/esbuild/lib/main.js
    ./node_modules/.pnpm/esbuild-register@3.6.0_esbuild@0.25.11/node_modules/esbuild-register/dist/node.js
    ./node_modules/.pnpm/drizzle-kit@0.31.5/node_modules/drizzle-kit/api.js
    ./node_modules/.pnpm/@payloadcms+drizzle@3.60.0_@types+pg@8.10.2_payload@3.60.0_graphql@16.11.0_typescript@5.7.3__pg@8.16.3/node_modules/@payloadcms/drizzle/dist/postgres/requireDrizzleKit.js
    ./node_modules/.pnpm/@payloadcms+db-postgres@3.60.0_payload@3.60.0_graphql@16.11.0_typescript@5.7.3_/node_modules/@payloadcms/db-postgres/dist/index.js
    ./src/payload.config.ts
    ./src/app/(payload)/api/graphql-playground/route.ts


./node_modules/.pnpm/@esbuild+darwin-arm64@0.25.11/node_modules/@esbuild/darwin-arm64/bin/esbuild
Reading source code for parsing failed
An unexpected error happened while trying to read the source code to parse: failed to convert rope into string

Caused by:
- invalid utf-8 sequence of 1 bytes from index 0

Import traces:
  #1 [App Route]:
    ./node_modules/.pnpm/@esbuild+darwin-arm64@0.25.11/node_modules/@esbuild/darwin-arm64/bin/esbuild
    ./node_modules/.pnpm/esbuild@0.25.11/node_modules/esbuild/lib/main.js
    ./node_modules/.pnpm/esbuild-register@3.6.0_esbuild@0.25.11/node_modules/esbuild-register/dist/node.js
    ./node_modules/.pnpm/drizzle-kit@0.31.5/node_modules/drizzle-kit/api.js
    ./node_modules/.pnpm/@payloadcms+drizzle@3.60.0_@types+pg@8.10.2_payload@3.60.0_graphql@16.11.0_typescript@5.7.3__pg@8.16.3/node_modules/@payloadcms/drizzle/dist/postgres/requireDrizzleKit.js
    ./node_modules/.pnpm/@payloadcms+db-postgres@3.60.0_payload@3.60.0_graphql@16.11.0_typescript@5.7.3_/node_modules/@payloadcms/db-postgres/dist/index.js
    ./src/payload.config.ts
    ./src/app/(payload)/api/graphql-playground/route.ts

  #2 [App Route]:
    ./node_modules/.pnpm/@esbuild+darwin-arm64@0.25.11/node_modules/@esbuild/darwin-arm64/bin/esbuild
    ./node_modules/.pnpm/esbuild@0.25.11/node_modules/esbuild/lib/main.js
    ./node_modules/.pnpm/esbuild-register@3.6.0_esbuild@0.25.11/node_modules/esbuild-register/dist/node.js
    ./node_modules/.pnpm/drizzle-kit@0.31.5/node_modules/drizzle-kit/api.js
    ./node_modules/.pnpm/@payloadcms+drizzle@3.60.0_@types+pg@8.10.2_payload@3.60.0_graphql@16.11.0_typescript@5.7.3__pg@8.16.3/node_modules/@payloadcms/drizzle/dist/postgres/requireDrizzleKit.js
    ./node_modules/.pnpm/@payloadcms+db-postgres@3.60.0_payload@3.60.0_graphql@16.11.0_typescript@5.7.3_/node_modules/@payloadcms/db-postgres/dist/index.js
    ./src/payload.config.ts
    ./src/app/(payload)/api/[...slug]/route.ts

  #3 [Server Component]:
    ./node_modules/.pnpm/@esbuild+darwin-arm64@0.25.11/node_modules/@esbuild/darwin-arm64/bin/esbuild
    ./node_modules/.pnpm/esbuild@0.25.11/node_modules/esbuild/lib/main.js
    ./node_modules/.pnpm/esbuild-register@3.6.0_esbuild@0.25.11/node_modules/esbuild-register/dist/node.js
    ./node_modules/.pnpm/drizzle-kit@0.31.5/node_modules/drizzle-kit/api.js
    ./node_modules/.pnpm/@payloadcms+drizzle@3.60.0_@types+pg@8.10.2_payload@3.60.0_graphql@16.11.0_typescript@5.7.3__pg@8.16.3/node_modules/@payloadcms/drizzle/dist/postgres/requireDrizzleKit.js
    ./node_modules/.pnpm/@payloadcms+db-postgres@3.60.0_payload@3.60.0_graphql@16.11.0_typescript@5.7.3_/node_modules/@payloadcms/db-postgres/dist/index.js
    ./src/payload.config.ts
    ./src/app/(frontend)/page.tsx

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.0.0: Wed Sep 17 21:35:32 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T6020
  Available memory (MB): 32768
  Available CPU cores: 12
Binaries:
  Node: 22.19.0
  npm: 10.9.3
  Yarn: 1.22.22
  pnpm: 10.18.3
Relevant Packages:
  next: 16.0.0-canary.15 // Latest available version is detected (16.0.0-canary.15).
  eslint-config-next: 15.4.4
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.7.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/alexortizl/nextjs-turbopack-issue

To Reproduce

  1. Install the project dependencies with pnpm install
  2. Run a production build with pnpm build

Current vs. Expected behavior

Current Behavior The build fails with the following error:

Error: Turbopack build failed with 3 errors:
./node_modules/.pnpm/@[email protected]/node_modules/@esbuild/darwin-arm64/README.md
Unknown module type
This module doesn't have an associated type. Use a known file extension, or register a loader for it.

Read more: https://nextjs.org/docs/app/api-reference/next-config-js/turbo#webpack-loaders

Import trace:
  App Route:
    ./node_modules/.pnpm/@[email protected]/node_modules/@esbuild/darwin-arm64/README.md
    ./node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js
    ./node_modules/.pnpm/[email protected][email protected]/node_modules/esbuild-register/dist/node.js
    ./node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/api.js
    ./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected][email protected]/node_modules/@payloadcms/drizzle/dist/postgres/requireDrizzleKit.js
    ./node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_/node_modules/@payloadcms/db-postgres/dist/index.js
    ./src/payload.config.ts
    ./src/app/(payload)/api/graphql-playground/route.ts


./node_modules/.pnpm/@[email protected]/node_modules/@esbuild/darwin-arm64/bin/esbuild
Reading source code for parsing failed
An unexpected error happened while trying to read the source code to parse: failed to convert rope into string

Caused by:
- invalid utf-8 sequence of 1 bytes from index 0

Import traces:
  #1 [App Route]:
    ./node_modules/.pnpm/@[email protected]/node_modules/@esbuild/darwin-arm64/bin/esbuild
    ./node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js
    ./node_modules/.pnpm/[email protected][email protected]/node_modules/esbuild-register/dist/node.js
    ./node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/api.js
    ./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected][email protected]/node_modules/@payloadcms/drizzle/dist/postgres/requireDrizzleKit.js
    ./node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_/node_modules/@payloadcms/db-postgres/dist/index.js
    ./src/payload.config.ts
    ./src/app/(payload)/api/graphql-playground/route.ts

  #2 [App Route]:
    ./node_modules/.pnpm/@[email protected]/node_modules/@esbuild/darwin-arm64/bin/esbuild
    ./node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js
    ./node_modules/.pnpm/[email protected][email protected]/node_modules/esbuild-register/dist/node.js
    ./node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/api.js
    ./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected][email protected]/node_modules/@payloadcms/drizzle/dist/postgres/requireDrizzleKit.js
    ./node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_/node_modules/@payloadcms/db-postgres/dist/index.js
    ./src/payload.config.ts
    ./src/app/(payload)/api/[...slug]/route.ts

  #3 [Server Component]:
    ./node_modules/.pnpm/@[email protected]/node_modules/@esbuild/darwin-arm64/bin/esbuild
    ./node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js
    ./node_modules/.pnpm/[email protected][email protected]/node_modules/esbuild-register/dist/node.js
    ./node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/api.js
    ./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected][email protected]/node_modules/@payloadcms/drizzle/dist/postgres/requireDrizzleKit.js
    ./node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_/node_modules/@payloadcms/db-postgres/dist/index.js
    ./src/payload.config.ts
    ./src/app/(frontend)/page.tsx

Expected behavior The build should complete without issues.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.0.0: Wed Sep 17 21:35:32 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T6020
  Available memory (MB): 32768
  Available CPU cores: 12
Binaries:
  Node: 22.19.0
  npm: 10.9.3
  Yarn: 1.22.22
  pnpm: 10.18.3
Relevant Packages:
  next: 16.0.0-canary.15 // Latest available version is detected (16.0.0-canary.15).
  eslint-config-next: 15.4.4
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.7.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next build (local), next dev (local)

Additional context

  • This project is based on the PayloadCMS official "blank" starter template but updated to Next.js 16.
  • The build passes with next build --webpack so I'm assuming it's an issue with Turbopack.

extent analysis

TL;DR

The most likely fix is to configure Turbopack to ignore certain files or modules that are causing the build to fail.

Guidance

  • Review the import traces to identify the modules causing the errors, such as @esbuild/darwin-arm64/README.md and @esbuild/darwin-arm64/bin/esbuild.
  • Consider adding a next.config.js configuration to exclude these modules from being processed by Turbopack.
  • Check the Next.js documentation on Turbopack configuration to see if there are any options available to ignore certain files or modules.
  • Try running the build with the --webpack flag to see if the issue is specific to Turbopack.

Example

No code example is provided as the issue is related to configuration and module imports.

Notes

The issue seems to be related to Turbopack not being able to handle certain modules or files, and the build passes when using Webpack. Further investigation is needed to determine the exact cause and solution.

Recommendation

Apply a workaround by configuring Turbopack to ignore the problematic modules or files, as the issue seems to be specific to Turbopack and not a general build issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING