nextjs - 💡(How to fix) Fix Module not found: Can't resolve './libsodium.mjs' with Turbopack [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#89366Fetched 2026-04-08 02:02:58
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
closed ×1commented ×1labeled ×1locked ×1

When using libsodium-wrappers (v0.7.15) with Next.js 15.2.8 and Turbopack enabled (next dev --turbopack), the build fails with a module resolution error.

Error Message

Module not found: Can't resolve './libsodium.mjs'

> 1 | import e from"./libsodium.mjs";let a;const r={},t=e.ready.then(function(){...

Root Cause

When using libsodium-wrappers (v0.7.15) with Next.js 15.2.8 and Turbopack enabled (next dev --turbopack), the build fails with a module resolution error.

Fix Action

Workaround

Running without Turbopack (next dev instead of next dev --turbopack) works correctly.

Code Example

Module not found: Can't resolve './libsodium.mjs'

> 1 | import e from"./libsodium.mjs";let a;const r={},t=e.ready.then(function(){...
RAW_BUFFERClick to expand / collapse

Summary

When using libsodium-wrappers (v0.7.15) with Next.js 15.2.8 and Turbopack enabled (next dev --turbopack), the build fails with a module resolution error.

Error

Module not found: Can't resolve './libsodium.mjs'

> 1 | import e from"./libsodium.mjs";let a;const r={},t=e.ready.then(function(){...

Environment

  • Next.js version: 15.2.8
  • Node.js version: (run node -v)
  • Operating System: macOS
  • Package manager: npm
  • libsodium-wrappers version: 0.7.15

Steps to Reproduce

  1. Create a Next.js project with Turbopack
  2. Install libsodium-wrappers: npm install libsodium-wrappers
  3. Import and use libsodium-wrappers in any component or API route
  4. Run next dev --turbopack
  5. Visit a page that uses the library

Expected Behavior

The module should resolve correctly and the application should run.

Actual Behavior

Build fails with Module not found: Can't resolve './libsodium.mjs'

Workaround

Running without Turbopack (next dev instead of next dev --turbopack) works correctly.

Additional Context

The libsodium-wrappers package uses dynamic imports and WASM files that Turbopack may not be handling correctly. The standard webpack bundler in Next.js resolves this without issues.

extent analysis

TL;DR

The most likely fix is to disable Turbopack by running next dev instead of next dev --turbopack to resolve the module resolution error with libsodium-wrappers.

Guidance

  • Verify that the issue is specific to Turbopack by comparing the behavior with and without Turbopack enabled.
  • Check the libsodium-wrappers documentation for any known issues or workarounds related to Turbopack compatibility.
  • Consider reporting the issue to the libsodium-wrappers or Next.js teams to investigate potential fixes or improvements for Turbopack support.
  • As a temporary workaround, use the standard webpack bundler by running next dev instead of next dev --turbopack to ensure the application runs correctly.

Example

No code snippet is provided as the issue is related to module resolution and build configuration rather than code-specific logic.

Notes

The issue seems to be related to Turbopack's handling of dynamic imports and WASM files used by libsodium-wrappers. Disabling Turbopack resolves the issue, but a more permanent solution may require updates to libsodium-wrappers or Next.js to improve Turbopack compatibility.

Recommendation

Apply the workaround by running next dev instead of next dev --turbopack, as it allows the application to run correctly while waiting for potential fixes or improvements in libsodium-wrappers or Next.js.

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