sveltejs/kit · error · Error
${path.relative('.', input)} does not exist
Error message
${path.relative('.', input)} does not exist What it means
`do_build` validates the resolved input directory (from normalize_options) with `fs.existsSync` before scanning/packaging. If the input directory is missing, it throws an error showing the input path relative to the current directory.
Source
Thrown at packages/package/src/index.js:35
/**
* @param {import('./types.js').Options} options
*/
export async function build(options) {
const { analyse_code, validate } = create_validator(options);
await do_build(options, analyse_code);
validate();
}
/**
* @param {import('./types.js').Options} options
* @param {(name: string, code: string) => void} analyse_code
*/
async function do_build(options, analyse_code) {
const { input, output, temp, extensions, alias, tsconfig } = normalize_options(options);
if (!fs.existsSync(input)) {
throw new Error(`${path.relative('.', input)} does not exist`);
}
fs.rmSync(temp, { force: true, recursive: true });
fs.mkdirSync(temp, { recursive: true });
const files = scan(input, extensions);
if (options.types) {
await emit_dts(input, temp, output, options.cwd, alias, files, tsconfig);
}
/** @type {Map<string, import('typescript').CompilerOptions>} */
const tsconfig_cache = new Map();
for (const file of files) {
await process_file(
input,
temp,View on GitHub (pinned to 03f1687fe6)
Solutions
- Create the expected directory or fix the path: ensure `src/lib` exists (default input).
- Pass the correct input explicitly: `svelte-package -i <dir>`.
- Run the command from the package root so relative input paths resolve correctly.
- Remove a stale `svelte` field in package.json if it points to a non-existent directory.
Example fix
// before (package.json) "svelte": "./src/Lib/index.js" // after "svelte": "./src/lib/index.js"
Defensive patterns
Strategy: validation
Validate before calling
import fs from 'node:fs';
if (!fs.existsSync('src/lib')) throw new Error('src/lib missing: set -i to your source dir'); Try / catch
try {
await run(['svelte-package']);
} catch (e) {
if (String(e.message).endsWith('does not exist')) {
throw new Error('Check the svelte-package -i input path and your cwd');
}
throw e;
} Prevention
- Run packaging scripts from the package root
- Keep the conventional src/lib layout or pass -i explicitly
- Remove stale `svelte`/config fields pointing at old paths after refactors
When it happens
Trigger: Running `svelte-package` (or `build`/`watch`) when the configured `input` directory (default `src/lib`, or `-i`/package.json `svelte` field value) does not exist on disk.
Common situations: Wrong cwd when invoking the CLI; typo'd `-i` path; renamed source folder (e.g. `src` instead of `src/lib`); config in package.json pointing at an old layout.
Related errors
- Failed to locate provided tsconfig or jsconfig
- You should change envPrefix (${env_prefix}) to avoid conflic
- Cloudflare Pages' _routes.json should be configured from the
- You should change envPrefix (${env_prefix}) to avoid conflic
- Invalid value for environment variable ${name}: ${JSON.strin
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/3779b3b32670d25b.
Report an issue: GitHub.