nextjs - 💡(How to fix) Fix Turbopack module resolution fails for installed packages in Next.js 16.0.6 [1 comments, 2 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#86779Fetched 2026-04-08 02:09:18
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
closed ×1commented ×1labeled ×1locked ×1

Next.js 16.0.6 with Turbopack fails to resolve react-map-gl and mapbox-gl packages during build, despite the packages being correctly installed in node_modules.

Error Message

Error: Turbopack build failed with 1 errors: ./components/intersections/intersection-map.tsx:4:1 Module not found: Can't resolve 'react-map-gl'

Root Cause

Next.js 16.0.6 with Turbopack fails to resolve react-map-gl and mapbox-gl packages during build, despite the packages being correctly installed in node_modules.

Fix Action

Workaround

Downgrading to Next.js 15.5.7 (which uses webpack) resolves the issue completely with identical code and dependencies.

Code Example

import Map from 'react-map-gl/mapbox'
import { Marker, NavigationControl } from 'react-map-gl/mapbox'

---

Error: Turbopack build failed with 1 errors:
./components/intersections/intersection-map.tsx:4:1
Module not found: Can't resolve 'react-map-gl'

---

$ npm list react-map-gl mapbox-gl
fieldatlas@0.1.0
├── mapbox-gl@3.16.0
└─┬ react-map-gl@8.1.0
  ├─┬ @vis.gl/react-mapbox@8.1.0
  │ └── mapbox-gl@3.16.0 deduped
  └── mapbox-gl@3.16.0 deduped

---

$ ls node_modules | grep -E 'react-map|mapbox'
@mapbox
mapbox-gl
react-map-gl

---

11:24:30.936 added 233 packages, and audited 234 packages in 11s
11:24:30.962 === CHECKING PACKAGES ===
11:24:31.355 fieldatlas@0.1.0 /vercel/path0
11:24:31.355 ├── mapbox-gl@3.16.0
11:24:31.356 └─┬ react-map-gl@8.1.0
11:24:31.364 @mapbox
11:24:31.364 mapbox-gl
11:24:31.364 react-map-gl
11:24:31.364 === END CHECK ===
[Then Turbopack build fails with "Module not found"]

---

"exports": {
  "./mapbox": {
    "types": "./dist/mapbox.d.ts",
    "require": "./dist/mapbox.cjs",
    "import": "./dist/mapbox.js"
  },
  "./maplibre": { ... }
}
RAW_BUFFERClick to expand / collapse

Turbopack module resolution fails for installed packages in Next.js 16.0.6

Submit this at: https://github.com/vercel/next.js/issues/new


Description

Next.js 16.0.6 with Turbopack fails to resolve react-map-gl and mapbox-gl packages during build, despite the packages being correctly installed in node_modules.

To Reproduce

Environment:

  • Next.js: 16.0.6
  • react-map-gl: 8.1.0
  • mapbox-gl: 3.16.0
  • Platform: Vercel deployment (also reproducible locally)

Steps:

  1. Install react-map-gl and mapbox-gl via npm
  2. Import from react-map-gl/mapbox in a component
  3. Run next build

Code:

import Map from 'react-map-gl/mapbox'
import { Marker, NavigationControl } from 'react-map-gl/mapbox'

Expected Behavior

Build should succeed since packages are installed in node_modules.

Actual Behavior

Build fails with:

Error: Turbopack build failed with 1 errors:
./components/intersections/intersection-map.tsx:4:1
Module not found: Can't resolve 'react-map-gl'

Evidence

Packages confirmed installed:

$ npm list react-map-gl mapbox-gl
[email protected]
├── [email protected]
└─┬ [email protected]
  ├─┬ @vis.gl/[email protected]
  │ └── [email protected] deduped
  └── [email protected] deduped

Packages exist in node_modules:

$ ls node_modules | grep -E 'react-map|mapbox'
@mapbox
mapbox-gl
react-map-gl

Yet Turbopack still reports "Module not found".

Attempted Fixes (None Worked)

  • ✗ Dynamic imports with ssr: false
  • ✗ Adding transpilePackages: ['react-map-gl', 'mapbox-gl']
  • ✗ Adding Turbopack resolveAlias config
  • ✗ Regenerating package-lock.json from scratch
  • ✗ Fresh npm ci install (deleted node_modules)
  • ✗ Clearing all Vercel build cache
  • ✗ Using different branch names
  • ✗ Adding postinstall scripts to force package installation

All attempts showed packages installed but Turbopack couldn't resolve them.

Workaround

Downgrading to Next.js 15.5.7 (which uses webpack) resolves the issue completely with identical code and dependencies.

Additional Context

Build Logs Show Packages Installed

From Vercel build with Next.js 16:

11:24:30.936 added 233 packages, and audited 234 packages in 11s
11:24:30.962 === CHECKING PACKAGES ===
11:24:31.355 [email protected] /vercel/path0
11:24:31.355 ├── [email protected]
11:24:31.356 └─┬ [email protected]
11:24:31.364 @mapbox
11:24:31.364 mapbox-gl
11:24:31.364 react-map-gl
11:24:31.364 === END CHECK ===
[Then Turbopack build fails with "Module not found"]

Import Paths

The package exports these paths correctly:

"exports": {
  "./mapbox": {
    "types": "./dist/mapbox.d.ts",
    "require": "./dist/mapbox.cjs",
    "import": "./dist/mapbox.js"
  },
  "./maplibre": { ... }
}

We're importing from the correct exported path (react-map-gl/mapbox).

Impact

  • Blocks using popular map libraries (react-map-gl, mapbox-gl, maplibre-gl) in Next.js 16
  • Forces downgrade to Next.js 15 (which triggers security warnings)
  • Likely affects other packages with similar export structures

System Info

  • OS: macOS (Darwin 25.0.0) and Vercel deployment environment
  • Node: v20+ LTS
  • Package manager: npm
  • Next.js: 16.0.6 (Turbopack) - FAILS
  • Next.js: 15.5.7 (webpack) - WORKS

Labels

bug, Turbopack, module-resolution


This issue is blocking production deployment of mapping features in our application.

extent analysis

TL;DR

The most likely fix is to configure Turbopack to correctly resolve the react-map-gl and mapbox-gl packages, potentially by adjusting the transpilePackages or resolveAlias configurations.

Guidance

  • Verify that the node_modules directory is correctly installed and that the packages are present by running npm list react-map-gl mapbox-gl and checking the node_modules directory.
  • Attempt to add react-map-gl and mapbox-gl to the transpilePackages configuration in next.config.js to ensure that Turbopack is correctly handling these packages.
  • Check the exports field in the package.json file of react-map-gl to ensure that the import paths are correctly configured.
  • Consider downgrading to Next.js 15.5.7 as a temporary workaround, as this version uses Webpack and does not exhibit the same issue.

Example

// next.config.js
module.exports = {
  //...
  turbopack: {
    transpilePackages: ['react-map-gl', 'mapbox-gl'],
  },
}

Notes

The issue appears to be specific to Turbopack in Next.js 16.0.6, and downgrading to Next.js 15.5.7 resolves the issue. However, this may not be a viable long-term solution due to potential security warnings.

Recommendation

Apply a workaround by adding react-map-gl and mapbox-gl to the transpilePackages configuration, as this may resolve the issue without requiring a downgrade to Next.js 15.5.7. If this does not work, consider downgrading to Next.js 15.5.7 as a temporary solution.

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

nextjs - 💡(How to fix) Fix Turbopack module resolution fails for installed packages in Next.js 16.0.6 [1 comments, 2 participants]