nextjs - 💡(How to fix) Fix Docs: outputFileTracingIncludes sharp example is outdated for sharp ≥ 0.33 (native binary moved to @img/*)

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…

Code Example

module.exports = {
  outputFileTracingIncludes: {
    '/*': ['node_modules/sharp/**/*', 'node_modules/aws-crt/dist/bin/**/*'],
  },
}

---

Could not load the "sharp" module using the <platform> runtime

---

module.exports = {
  outputFileTracingIncludes: {
    '/*': [
      'node_modules/sharp/**/*',
      'node_modules/@img/**/*',
      'node_modules/aws-crt/dist/bin/**/*',
    ],
  },
}
RAW_BUFFERClick to expand / collapse

Which docs page

output config → outputFileTracingIncludes

The "Common include patterns for native/runtime assets" example:

module.exports = {
  outputFileTracingIncludes: {
    '/*': ['node_modules/sharp/**/*', 'node_modules/aws-crt/dist/bin/**/*'],
  },
}

Problem

This example is stale for sharp ≥ 0.33 (current 0.33.5). In 0.33, sharp moved its prebuilt native libvips binaries out of node_modules/sharp/ into separate packages under @img/* (e.g. @img/sharp-linux-x64, @img/sharp-libvips-linux-x64). npm hoists those as siblings of sharp in node_modules, not children.

Verified on a fresh sharp 0.33.5 install:

  • find node_modules/sharp -name '*.node'0 files — there is no native binary under sharp/ anymore.
  • The binary loaded at runtime lives at node_modules/@img/sharp-<platform>/ and node_modules/@img/sharp-libvips-<platform>/.

So node_modules/sharp/**/* no longer captures the native binary sharp must load at runtime. A serverless function traced with only that glob throws at the first require('sharp'):

Could not load the "sharp" module using the <platform> runtime

(If sharp's JS deps are also untraced — e.g. when sharp is reached through a dynamic/turbopackIgnore'd import so @vercel/nft can't follow it statically — you additionally get Cannot find module 'detect-libc'.)

Suggested fix

Update the example to also include @img:

module.exports = {
  outputFileTracingIncludes: {
    '/*': [
      'node_modules/sharp/**/*',
      'node_modules/@img/**/*',
      'node_modules/aws-crt/dist/bin/**/*',
    ],
  },
}

Optionally add a one-line note that these globs supplement static tracing: when sharp is statically imported, @vercel/nft pulls in its pure-JS deps (color, detect-libc, semver, …) automatically; the explicit globs are only needed for the native files nft can't follow.

Environment

  • Next.js 16.2.7
  • sharp 0.33.5
  • npm (hoisted node_modules)

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