sveltejs/kit · warning
Warning: The following modules failed to locate dependencies
Error message
Warning: The following modules failed to locate dependencies that may (or may not) be required for your app to work:
What it means
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.
Source
Thrown at packages/adapter-vercel/index.js:580
if (error.message.startsWith('Failed to parse')) return;
if (error.message.startsWith('Failed to resolve dependency')) {
const match = /Cannot find module '(.+?)' loaded from (.+)/;
const [, module, importer] = match.exec(error.message) ?? [, error.message, '(unknown)'];
if (!resolution_failures.has(importer)) {
resolution_failures.set(importer, []);
}
/** @type {string[]} */ (resolution_failures.get(importer)).push(module);
} else {
throw error;
}
});
if (resolution_failures.size > 0) {
const cwd = process.cwd();
builder.log.warn(
'Warning: The following modules failed to locate dependencies that may (or may not) be required for your app to work:'
);
for (const [importer, modules] of resolution_failures) {
console.error(` ${path.relative(cwd, importer)}`);
for (const module of modules) {
console.error(` - \u001B[1m\u001B[36m${module}\u001B[39m\u001B[22m`);
}
}
}
const files = Array.from(traced.fileList);
// find common ancestor directory
/** @type {string[]} */
let common_parts = files[0]?.split(path.sep) ?? [];
for (let i = 1; i < files.length; i += 1) {View on GitHub (pinned to 03f1687fe6)
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.
Example fix
// before npm i # sharp present but @img/sharp-lib optional variants absent # after npm i -D @img/sharp-linux-x64 # or install the missing dependency named in the warning
Defensive patterns
Strategy: validation
Validate before calling
// Pre-build dependency sanity check
import { existsSync } from 'node:fs';
for (const dep of optionalDeps) {
if (!existsSync(`node_modules/${dep}`)) console.warn(`Unresolved dep likely in bundle: ${dep}`);
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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).
Related errors
- Warning: The following routes have an ISR config which is i
- Warning: vercel.json defines cron tasks that use paths that
- The `edge` runtime is no longer supported
- Could not find entry point
- Could not auto-detect a runtime. Please explicitly specify a
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/3f8ec19f85bf50eb.
Report an issue: GitHub.