{"record":{"id":"af1569a1417508fb","repo":"sveltejs/kit","slug":"could-not-resolve-peer-dependency-name-relati","errorCode":null,"errorMessage":"Could not resolve peer dependency \"${name}\" relative to your project — please install it and try again.","messagePattern":"Could not resolve peer dependency \"(.+?)\" relative to your project — please install it and try again\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/adapter-auto/index.js","lineNumber":57,"sourceCode":"\t\treturn manager;\n\t} catch {\n\t\treturn 'npm';\n\t}\n}\n\n/**\n * Resolves a peer dependency relative to the current CWD. Duplicated with `packages/kit`\n * @param {string} dependency\n */\nfunction resolve_peer(dependency) {\n\tlet [name, ...parts] = dependency.split('/');\n\tif (name[0] === '@') name += `/${parts.shift()}`;\n\n\tlet dir = process.cwd();\n\n\twhile (!fs.existsSync(`${dir}/node_modules/${name}/package.json`)) {\n\t\tif (dir === (dir = path.dirname(dir))) {\n\t\t\tthrow new Error(\n\t\t\t\t`Could not resolve peer dependency \"${name}\" relative to your project — please install it and try again.`\n\t\t\t);\n\t\t}\n\t}\n\n\tconst pkg_dir = `${dir}/node_modules/${name}`;\n\tconst pkg = JSON.parse(fs.readFileSync(`${pkg_dir}/package.json`, 'utf-8'));\n\n\tconst subpackage = ['.', ...parts].join('/');\n\n\tlet exported = pkg.exports[subpackage];\n\n\twhile (typeof exported !== 'string') {\n\t\tif (!exported) {\n\t\t\tthrow new Error(`Could not find valid \"${subpackage}\" export in ${name}/package.json`);\n\t\t}\n\n\t\texported = exported['import'] ?? exported['default'];","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/adapter-auto/index.js#L39-L75","documentation":"adapter-auto resolves its peer adapter packages (e.g. @sveltejs/adapter-node) by walking up from process.cwd() looking for node_modules/<name>/package.json. When the directory walk reaches the filesystem root without finding the package, it throws this error meaning the detected environment's adapter is not installed in the project.","triggerScenarios":"get_adapter detected a deployment environment (via environment variables), mapped it to an adapter module name, and resolve_peer could not find that package's package.json in any node_modules directory between the project root and the filesystem root.","commonSituations":"Fresh CI environments where devDependencies were not installed (e.g. npm install --production or pnpm install --prod); monorepos where the adapter is in a different workspace package that isn't hoisted; adapters deleted from package.json while relying on auto-detection.","solutions":["Install the adapter the auto-detector chose: npm i -D @sveltejs/adapter-node (or whichever adapter matches your platform).","Check package.json devDependencies include the adapter and run a full install (not --production).","In monorepos, add the adapter to the app package's devDependencies or configure hoisting so it lands in a resolvable node_modules.","Bypass auto-detection by importing the specific adapter directly in svelte.config.js."],"exampleFix":"// before\n// svelte.config.js uses adapter-auto, deploying to Vercel without the adapter installed\n// after\nimport adapter from '@sveltejs/adapter-vercel';\nexport default { kit: { adapter: adapter() } };","handlingStrategy":"validation","validationCode":"import fs from 'node:fs';\nimport path from 'node:path';\nconst adapters = ['@sveltejs/adapter-node','@sveltejs/adapter-vercel','@sveltejs/adapter-netlify','@sveltejs/adapter-cloudflare','@sveltejs/adapter-bun'];\nconst resolvable = (name) => {\n  let dir = process.cwd();\n  while (true) {\n    if (fs.existsSync(path.join(dir, 'node_modules', name, 'package.json'))) return true;\n    const parent = path.dirname(dir);\n    if (parent === dir) return false;\n    dir = parent;\n  }\n};\n// before build: ensure the adapter you expect is resolvable\nif (!adapters.some(resolvable)) throw new Error('No platform adapter installed — add one to devDependencies');","typeGuard":"const isAdapterInstalled = (name) => {\n  let dir = process.cwd();\n  while (true) {\n    if (fs.existsSync(path.join(dir, 'node_modules', name, 'package.json'))) return true;\n    const parent = path.dirname(dir);\n    if (parent === dir) return false;\n    dir = parent;\n  }\n};","tryCatchPattern":"try {\n  await build();\n} catch (e) {\n  const m = /Could not resolve peer dependency \"([^\"]+)\"/.exec(e.message);\n  if (m) {\n    console.error(`Missing adapter ${m[1]}. Run: npm i -D ${m[1]}`);\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Commit the platform adapter to package.json devDependencies instead of relying on adapter-auto alone","Never install with --production/--prod for build pipelines","In monorepos, declare the adapter in the app package that runs the build","Verify node_modules contents after fresh CI checkouts"],"tags":["dependency-resolution","adapter-auto","node-modules"],"backgroundTag":"peer-dependency-not-found","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}