{"record":{"id":"efae7dcfdbc6b562","repo":"sveltejs/kit","slug":"lib-has-been-removed-use-lib-instead-https","errorCode":null,"errorMessage":"`$lib` has been removed. Use `#lib` instead: https://svelte.dev/docs/kit/$lib. To keep using `$lib`, add `alias: { '$lib': 'src/lib' }` to your SvelteKit config.","messagePattern":"`\\$lib` has been removed\\. Use `#lib` instead: https://svelte\\.dev/docs/kit/\\$lib\\. To keep using `\\$lib`, add `alias: (.+?)` to your SvelteKit config\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/exports/vite/index.js","lineNumber":320,"sourceCode":"\t\t\toptions: svelte_config\n\t\t},\n\t\tresolveId: {\n\t\t\tfilter: { id: removed_modules.map(({ pattern }) => pattern) },\n\t\t\tasync handler(id, importer, options) {\n\t\t\t\tconst resolved = await this.resolve(id, importer, { ...options, skipSelf: true });\n\t\t\t\tif (resolved) return resolved;\n\n\t\t\t\tconst aliases = svelte_config.alias;\n\t\t\t\tfor (const { name, pattern, message } of removed_modules) {\n\t\t\t\t\tif (!pattern.test(id)) continue;\n\n\t\t\t\t\t// If the user re-added an alias for this module (as the migration message\n\t\t\t\t\t// suggests), a failed resolution means a genuine missing file rather than\n\t\t\t\t\t// use of the removed module. Let Vite report the real \"not found\" error\n\t\t\t\t\t// instead of the misleading migration message.\n\t\t\t\t\tif (name in aliases || `${name}/*` in aliases) return;\n\n\t\t\t\t\tthrow stackless(message);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Build the SvelteKit-provided Vite config to be merged with the user's vite.config.js file.\n\t\t * @see https://vitejs.dev/guide/api-plugin.html#config\n\t\t */\n\t\tconfig: {\n\t\t\torder: 'pre',\n\t\t\thandler(config, config_env) {\n\t\t\t\tinitial_config = config;\n\t\t\t\tis_build = config_env.command === 'build';\n\n\t\t\t\tkit = process_config(svelte_config, root);\n\t\t\t\tout_dir = posixify(kit.outDir);\n\t\t\t\tout = `${out_dir}/output`;\n","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/exports/vite/index.js#L302-L338","documentation":"Vite resolveId hook guard in the SvelteKit plugin: an import matched the removed $lib alias pattern and failed to resolve any other way. $lib was replaced by the #lib alias; the error explains the removal, links the migration docs, and offers the escape hatch of re-adding $lib manually via the alias config.","triggerScenarios":"Thrown at packages/kit/src/exports/vite/index.js:320 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace $lib imports with #lib, e.g. `import x from '#lib/x'`","Add `alias: { '$lib': 'src/lib' }` to the SvelteKit config to keep using $lib temporarily","Run the migration to bulk-rewrite $lib imports"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}