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

  1. Create the expected directory or fix the path: ensure `src/lib` exists (default input).
  2. Pass the correct input explicitly: `svelte-package -i <dir>`.
  3. Run the command from the package root so relative input paths resolve correctly.
  4. 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

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


AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02). Data as JSON: /api/errors/3779b3b32670d25b. Report an issue: GitHub.