sveltejs/kit · error · Error

config.package is no longer supported. See https://github.co

Error message

config.package is no longer supported. See https://github.com/sveltejs/kit/pull/8922 for more information and how to migrate.

What it means

@sveltejs/package no longer reads a `package` section from svelte.config.js. In PR #8922 all packaging options moved from `config.package` to the CLI's own options file, so the CLI deliberately throws if the legacy key is still present, forcing migration rather than silently ignoring the settings.

Source

Thrown at packages/package/src/cli.js:77

const { values } = parsed;

if (values.version) {
	console.log(pkg.version);
	process.exit(0);
}

if (values.help) {
	console.log(help);
	process.exit(0);
}

try {
	const config = await load_config();

	// @ts-expect-error
	if (config.package) {
		throw new Error(
			'config.package is no longer supported. See https://github.com/sveltejs/kit/pull/8922 for more information and how to migrate.'
		);
	}

	const packaging = await import('./index.js');

	/** @type {Options} */
	const options = {
		cwd: process.cwd(),
		input: values.input ?? config.files?.lib ?? 'src/lib',
		output: values.output,
		preserve_output: values['preserve-output'],
		tsconfig: values.tsconfig,
		types: values.types,
		config
	};

	await (values.watch ? packaging.watch(options) : packaging.build(options));

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Remove the `package` object from svelte.config.js.
  2. Move packaging settings to a package.json `svelte` field or CLI flags per the migration guide at github.com/sveltejs/kit/pull/8922.
  3. Update the build script to the new `svelte-package -i src/lib -o dist` style invocation.

Example fix

// before (svelte.config.js)
const config = {
  preprocess: vitePreprocess(),
  package: { exports: (filepath) => !/_internal/ } };

// after
const config = {
  preprocess: vitePreprocess()
};
// then in package.json:
// "scripts": { "build": "svelte-package -i src/lib" }
Defensive patterns

Strategy: validation

Validate before calling

import { config } from './svelte.config.js';
if ('package' in config) throw new Error('remove config.package before svelte-package v2');

Try / catch

try {
  await run(['svelte-package']);
} catch (e) {
  if (String(e.message).includes('config.package is no longer supported')) {
    throw new Error('Migrate packaging options out of svelte.config.js (PR #8922)');
  }
  throw e;
}

Prevention

When it happens

Trigger: Running `svelte-package` (via `pnpm build`/npm script) in a project whose svelte.config.js still contains a top-level `package: { ... }` object.

Common situations: Upgrading an older SvelteKit/library project from @sveltejs/package v1 to v2 without removing the old config section; copying a stale svelte.config.js from an older template.

Related errors


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