{"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":"        'VipsForeignLoadTiff',\n        'VipsForeignLoadWebp',\n      ],\n    })\n    if (typeof operationCache === 'boolean') {\n      _sharp.cache(operationCache)\n    }\n    if (_sharp.concurrency() > 1) {\n      // Reducing concurrency should reduce the memory usage too.\n      // We more aggressively reduce in dev but also reduce in prod.\n      // https://sharp.pixelplumbing.com/api-utility#concurrency\n      const divisor = process.env.NODE_ENV === 'development' ? 4 : 2\n      _sharp.concurrency(\n        concurrency ?? Math.floor(Math.max(_sharp.concurrency() / divisor, 1))\n      )\n    }\n  } catch (e: unknown) {\n    if (isError(e) && e.code === 'MODULE_NOT_FOUND') {\n      throw new Error(\n        'Module `sharp` not found. Please run `npm install --cpu=wasm32 sharp` to install it.'\n      )\n    }\n    throw e\n  }\n  return _sharp\n}\n\nexport interface ImageParamsResult {\n  href: string\n  isAbsolute: boolean\n  isStatic: boolean\n  width: number\n  quality: number\n  mimeType: string\n  sizes: number[]\n  minimumCacheTTL: number\n}","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/image-optimizer.ts#L103-L139","documentation":"Thrown by the image optimizer when require('sharp') throws MODULE_NOT_FOUND. Next.js uses sharp for server-side image optimization; when it is not installed (or only present for the wrong CPU), the catch block detects MODULE_NOT_FOUND and rethrows this actionable message instructing the wasm32 install. Any other require error is rethrown unchanged.","triggerScenarios":"A request hits /_next/image (or the image optimizer) and sharp has not been installed. The require('sharp') at line 94 throws with code 'MODULE_NOT_FOUND', caught and converted to this message.","commonSituations":"Fresh install where sharp is an optional dependency that did not install. Deploying to a platform (e.g. wasm/edge or a minimal image) where the native sharp binary is unavailable. Using a package manager that skipped optionalDependencies. Manually removing sharp to slim node_modules.","solutions":["Run the command in the message: `npm install --cpu=wasm32 sharp` (or the package-manager equivalent).","If you don't need optimization, disable it via images.unoptimized: true in next.config.","For native performance on a supported platform, run `npm install sharp` to fetch the correct binary.","After installing, restart the dev/prod server so sharp is required again."],"exampleFix":"// before: next.config.js with optimization enabled but sharp missing\nmodule.exports = {}\n\n// after: either install sharp (`npm install --cpu=wasm32 sharp`) or disable optimization\nmodule.exports = {\n  images: { unoptimized: true },\n}","handlingStrategy":"fallback","validationCode":"// Detect missing sharp before the optimizer is hit; fall back to unoptimized\nfunction resolveImagesConfig() {\n  try { require.resolve('sharp') } catch {\n    return { images: { unoptimized: true } } // graceful fallback\n  }\n  return { images: {} }\n}","typeGuard":null,"tryCatchPattern":"try {\n  _sharp = require('sharp')\n} catch (e: unknown) {\n  if (isError(e) && e.code === 'MODULE_NOT_FOUND') {\n    throw new Error('Module `sharp` not found. ...')\n  }\n  throw e\n}","preventionTips":["Install sharp explicitly in production deps.","Set images.unoptimized on platforms that can't run native sharp.","Add a health check that require.resolve('sharp') succeeds in CI."],"tags":["image-optimization","sharp","dependencies","wasm"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}