nextjs - 💡(How to fix) Fix The `.next/standalone/` output folder doesn't contain any sourcemaps [4 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#89917Fetched 2026-04-08 00:21:04
View on GitHub
Comments
4
Participants
2
Timeline
7
Reactions
1
Author
Participants
Timeline (top)
commented ×4issue_type_added ×1labeled ×1subscribed ×1

Root Cause

I noticed because we run the app with node --enable-source-maps, but the stack traces still contained references to minified files. A fix for this issue will make my debugging sessions much easier 🙇

Code Example

~/code/test-next[main]% pnpm run build
~/code/test-next[main]% find .next/standalone/.next/server/chunks -name '*.js.map' | wc -l
       0
~/code/test-next[main]% find .next/server/chunks -name '*.js.map' | wc -l
      27

---

~/code/test-next[main]% grep -r sourceMappingURL .next/standalone/.next/server/chunks | wc -l
      27

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:56 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 14
Binaries:
  Node: 25.6.1
  npm: 11.9.0
  Yarn: 1.22.22
  pnpm: 10.29.3
Relevant Packages:
  next: 16.2.0-canary.37 // Latest available version is detected (16.2.0-canary.37).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: standalone
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/afgomez/test-next

To Reproduce

Not all sourcemaps are copied over when building a standalone build.

~/code/test-next[main]% pnpm run build
~/code/test-next[main]% find .next/standalone/.next/server/chunks -name '*.js.map' | wc -l
       0
~/code/test-next[main]% find .next/server/chunks -name '*.js.map' | wc -l
      27

However, the copied files do reference a sourcemap

~/code/test-next[main]% grep -r sourceMappingURL .next/standalone/.next/server/chunks | wc -l
      27

Current vs. Expected behavior

Expected:

  • All sourcemaps are copied into the standalone/ folder.

Actual:

  • No sourcemaps are copied into the standalone/ folder.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:56 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 14
Binaries:
  Node: 25.6.1
  npm: 11.9.0
  Yarn: 1.22.22
  pnpm: 10.29.3
Relevant Packages:
  next: 16.2.0-canary.37 // Latest available version is detected (16.2.0-canary.37).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: standalone

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

Output

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

next build (local)

Additional context

I can also reproduce this issue in Next 16.1.5.

I could not find anything in the docs mentioning that this is expected behaviour, or that it is configurable in any way.

I noticed because we run the app with node --enable-source-maps, but the stack traces still contained references to minified files. A fix for this issue will make my debugging sessions much easier 🙇

extent analysis

Fix Plan

Step 1: Update next.config.js to include sourcemaps in standalone build

Add the following configuration to your next.config.js file:

module.exports = {
  // ... other configurations ...
  output: {
    standalone: {
      sourcemaps: true,
    },
  },
};

This will enable sourcemaps for the standalone build.

Step 2: Run pnpm run build again

Run the build command again to ensure that sourcemaps are copied over:

pnpm run build

Step 3: Verify sourcemaps are present in standalone build

Check that the sourcemaps are present in the standalone build directory:

find .next/standalone/.next/server/chunks -name '*.js.map' | wc -l

This should output a non-zero number, indicating that sourcemaps are present.

Step 4: Verify sourcemaps are referenced in standalone build

Check that the copied files reference the sourcemaps:

grep -r sourceMappingURL .next/standalone/.next/server/chunks | wc -l

This should output a non-zero number, indicating that sourcemaps are referenced.

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