{"record":{"id":"02923ad6eecaffbe","repo":"sveltejs/kit","slug":"defineenvvars-has-moved-import-it-from-svelt","errorCode":null,"errorMessage":"`defineEnvVars` has moved — import it from `@sveltejs/kit/env` instead","messagePattern":"`defineEnvVars` has moved — import it from `@sveltejs/kit/env` instead","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/kit/src/exports/hooks/index.js","lineNumber":7,"sourceCode":"export { sequence } from './sequence.js';\n\n/**\n * @internal\n */\nexport function defineEnvVars() {\n\tthrow new Error(`\\`defineEnvVars\\` has moved — import it from \\`@sveltejs/kit/env\\` instead`);\n}\n","sourceCodeStart":1,"sourceCodeEnd":9,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/exports/hooks/index.js#L1-L9","documentation":"defineEnvVars was an internal SvelteKit API that has been removed from its old import location. Calling the stub exported from @sveltejs/kit always throws this migration message. It exists purely to point developers at the new import path rather than failing with an opaque 'undefined is not a function'.","triggerScenarios":"Importing { defineEnvVars } from '@sveltejs/kit' (or deep paths resolving to exports/hooks/index.js) and calling it — typically in a vite.config or svelte.config after upgrading SvelteKit.","commonSituations":"Upgrading from an older SvelteKit version where defineEnvVars was importable from '@sveltejs/kit'; following outdated tutorials or vendored Vite plugin code that still used it.","solutions":["Remove the defineEnvVars call entirely — modern SvelteKit/Vite handles env loading automatically via import.meta.env and $env modules.","If you truly need env helpers, import from '@sveltejs/kit/env' (per the error message) or use Vite's loadEnv in config files.","Update any copied vite plugin/config code to the current @sveltejs/vite-plugin-svelte + SvelteKit API surface."],"exampleFix":"// before\nimport { defineEnvVars } from '@sveltejs/kit';\ndefineEnvVars();\n// after\n// delete the call; use $env/static/public in app code or Vite loadEnv in config\nimport { loadEnv } from 'vite';","handlingStrategy":"try-catch","validationCode":"import * as kit from '@sveltejs/kit';\nif (typeof kit.defineEnvVars === 'function' && /moved/.test(String(kit.defineEnvVars))) {\n  console.warn('defineEnvVars is removed; drop the call or import from @sveltejs/kit/env');\n}","typeGuard":"function isRemovedApiError(e) {\n  return e instanceof Error && e.message.includes('defineEnvVars` has moved');\n}","tryCatchPattern":"try {\n  defineEnvVars();\n} catch (e) {\n  if (e.message.includes('has moved')) {\n    console.warn('Migrating away from defineEnvVars — no action needed beyond removing this call.');\n  } else {\n    throw e;\n  }\n}","preventionTips":["Read the SvelteKit changelog/migration guide when upgrading major versions.","Search your codebase for defineEnvVars imports before upgrading.","Avoid copying vite config snippets from outdated tutorials; use current @sveltejs/kit docs."],"tags":["sveltekit","api-migration","breaking-change","env"],"backgroundTag":"removed-api-migration","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}