{"record":{"id":"3f8ec19f85bf50eb","repo":"sveltejs/kit","slug":"warning-the-following-modules-failed-to-locate-de","errorCode":null,"errorMessage":"Warning: The following modules failed to locate dependencies that may (or may not) be required for your app to work:","messagePattern":"Warning: The following modules failed to locate dependencies that may \\(or may not\\) be required for your app to work:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/adapter-vercel/index.js","lineNumber":580,"sourceCode":"\t\tif (error.message.startsWith('Failed to parse')) return;\n\n\t\tif (error.message.startsWith('Failed to resolve dependency')) {\n\t\t\tconst match = /Cannot find module '(.+?)' loaded from (.+)/;\n\t\t\tconst [, module, importer] = match.exec(error.message) ?? [, error.message, '(unknown)'];\n\n\t\t\tif (!resolution_failures.has(importer)) {\n\t\t\t\tresolution_failures.set(importer, []);\n\t\t\t}\n\n\t\t\t/** @type {string[]} */ (resolution_failures.get(importer)).push(module);\n\t\t} else {\n\t\t\tthrow error;\n\t\t}\n\t});\n\n\tif (resolution_failures.size > 0) {\n\t\tconst cwd = process.cwd();\n\t\tbuilder.log.warn(\n\t\t\t'Warning: The following modules failed to locate dependencies that may (or may not) be required for your app to work:'\n\t\t);\n\n\t\tfor (const [importer, modules] of resolution_failures) {\n\t\t\tconsole.error(`  ${path.relative(cwd, importer)}`);\n\t\t\tfor (const module of modules) {\n\t\t\t\tconsole.error(`    - \\u001B[1m\\u001B[36m${module}\\u001B[39m\\u001B[22m`);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst files = Array.from(traced.fileList);\n\n\t// find common ancestor directory\n\t/** @type {string[]} */\n\tlet common_parts = files[0]?.split(path.sep) ?? [];\n\n\tfor (let i = 1; i < files.length; i += 1) {","sourceCodeStart":562,"sourceCodeEnd":598,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/adapter-vercel/index.js#L562-L598","documentation":"During create_function_bundle, the Vercel adapter (via esbuild/nft-style tracing) tries to resolve every import of every bundled module. Imports that cannot be resolved are recorded in `resolution_failures` and reported with this warning: the code may require those packages at runtime, but they were not traced into the function bundle. It says 'may (or may not)' because some failures are for optional or dynamically-loaded dependencies that never execute.","triggerScenarios":"Running generate_serverless_function when esbuild's onResolve handler fails for one or more importers' modules (e.g. optional peer dependencies, native/dynamic requires, packages not in node_modules at build time).","commonSituations":"Dependencies imported dynamically or conditionally that are missing from package.json; optional peer deps of frameworks; monorepo workspace links that don't resolve under the bundler; platform-specific optional dependencies (e.g. sharp variants).","solutions":["Add the unresolved packages to your package.json dependencies and reinstall so the tracer can resolve them.","If the module is optional and genuinely unused, ignore the warning.","Check the listed importer paths to identify which package's optional dependency is failing and install that parent's peer deps.","Use the `external` adapter option to mark packages that should stay external to the bundle and be installed at runtime instead."],"exampleFix":"// before\nnpm i   # sharp present but @img/sharp-lib optional variants absent\n# after\nnpm i -D @img/sharp-linux-x64  # or install the missing dependency named in the warning","handlingStrategy":"validation","validationCode":"// Pre-build dependency sanity check\nimport { existsSync } from 'node:fs';\nfor (const dep of optionalDeps) {\n  if (!existsSync(`node_modules/${dep}`)) console.warn(`Unresolved dep likely in bundle: ${dep}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install optional/dynamic dependencies explicitly in package.json","Mark runtime-installed packages as external via the adapter's external option","Read the build log's failing importer list after every dependency change"],"tags":["vercel","adapter","module-resolution","bundling","build-warning"],"backgroundTag":"module-not-found","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}