{"record":{"id":"08d7826b6e5d1d35","repo":"vercel/next.js","slug":"module-sharp-not-found-please-run-npm-install","errorCode":null,"errorMessage":"Module `sharp` not found. Please run `npm install --cpu=wasm32 sharp` to install it.","messagePattern":"Module `sharp` not found\\. Please run `npm install --cpu=wasm32 sharp` to install it\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/server/image-optimizer.ts","lineNumber":121,"sourceCode":"  }\n\n  const dir = join(/* turbopackIgnore: true */ cacheDir, cacheKey)\n  const filename = join(\n    /* turbopackIgnore: true */\n    dir,\n    `${maxAge}.${expireAt}.${etag}.${upstreamEtag}.${extension}`\n  )\n\n  await promises.rm(dir, { recursive: true, force: true }).catch(() => {})\n\n  await promises.mkdir(dir, { recursive: true })\n  await promises.writeFile(filename, buffer)\n}\n\nasync function readFromCacheDir(cacheDir: string, cacheKey: string) {\n  const dir = join(/* turbopackIgnore: true */ cacheDir, cacheKey)\n  const files = await promises.readdir(dir)\n  const file = files[0]\n  if (!file) {\n    throw new Error(\n      `Invariant: cache entry \"${cacheKey}\" not found in dir \"${cacheDir}\"`\n    )\n  }\n  const [maxAgeSt, expireAtSt, etag, upstreamEtag, extension] = file.split(\n    '.',\n    5\n  )\n  const filePath = join(/* turbopackIgnore: true */ dir, file)\n  const buffer = await promises.readFile(/* turbopackIgnore: true */ filePath)\n  if (buffer.byteLength === 0) {\n    throw new Error(`Invariant: image cache entry \"${cacheKey}\" is empty`)\n  }\n  const expireAt = Number(expireAtSt)\n  const maxAge = Number(maxAgeSt)\n  return { maxAge, expireAt, etag, upstreamEtag, buffer, extension }\n}","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/vercel/next.js/blob/996f957c060aa17957a166216c69565c72996f4a/packages/next/src/server/image-optimizer.ts#L103-L139","documentation":"Thrown from readFromCacheDir when Next.js cannot load the sharp image processing library on a wasm32 target. The error surfaces from the catch of the sharp import/initialization and points the user at the wasm-specific install command; it means the runtime dependency for image optimization is simply absent.","triggerScenarios":"The sharp module is required for image optimization but not installed.","commonSituations":"Running image optimization in an environment where sharp must be installed manually (e.g. wasm32).","solutions":["Run npm install --cpu=wasm32 sharp to install the wasm build of sharp."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"996f957c060aa17957a166216c69565c72996f4a","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}