{"record":{"id":"ecaa92703d2d8ca3","repo":"vitejs/vite","slug":"environment-name-is-not-defined-in-the-config-ecaa92","errorCode":null,"errorMessage":"Environment \"${name}\" is not defined in the config.","messagePattern":"Environment \"(.+?)\" is not defined in the config\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vite/src/node/server/environment.ts","lineNumber":120,"sourceCode":"  /**\n   * Hot channel for this environment. If not provided or disabled,\n   * it will be a noop channel that does nothing.\n   *\n   * @example\n   * environment.hot.send({ type: 'full-reload' })\n   */\n  hot: NormalizedHotChannel\n\n  public bundledDev?: BundledDev\n\n  constructor(\n    name: string,\n    config: ResolvedConfig,\n    context: DevEnvironmentContext,\n  ) {\n    let options = config.environments[name]\n    if (!options) {\n      throw new Error(`Environment \"${name}\" is not defined in the config.`)\n    }\n    if (context.options) {\n      options = mergeConfig(\n        options,\n        context.options,\n      ) as ResolvedEnvironmentOptions\n    }\n    super(name, config, options)\n    if (\n      options.isBundled ||\n      (name === 'client' && config.experimental.bundledDev)\n    ) {\n      context.disableDepsOptimizer = true\n      this.bundledDev = new BundledDev(this)\n    }\n\n    this._pendingRequests = new Map()\n","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/vitejs/vite/blob/b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab/packages/vite/src/node/server/environment.ts#L102-L138","documentation":"DevEnvironment's constructor looks up config.environments[name]; if there is no entry for the requested name, it throws. Every DevEnvironment must correspond to a resolved environment in the config (default 'client' and 'ssr' are auto-created).","triggerScenarios":"Constructing a DevEnvironment with a name not present in resolved config.environments — e.g. instantiating a custom RTE/worker environment before declaring it under the 'environments' key, or a typo in the name.","commonSituations":"Custom integrations creating environments dynamically, framework adapters that pass a name mismatched to config, or removing an environment from config while code still references it.","solutions":["Declare the environment under the 'environments' key in vite.config before constructing it.","Verify the name string matches exactly (case-sensitive) between config and constructor.","Use the default 'client'/'ssr' unless you intentionally add custom environments.","If the environment was removed intentionally, also remove the code that constructs it."],"exampleFix":"// before\nnew DevEnvironment('rte', config, context) // 'rte' not in config\n// after — vite.config.ts\nenvironments: { rte: { ... } }\n// then\nnew DevEnvironment('rte', config, context)","handlingStrategy":"validation","validationCode":"function assertEnvironmentDeclared(config, name) {\n  if (!(name in (config.environments ?? {}))) {\n    throw new Error(`Declare environments.${name} in vite.config before constructing it`)\n  }\n}\nassertEnvironmentDeclared(config, name)","typeGuard":"function isDeclaredEnvironment(config, name): boolean {\n  return Object.prototype.hasOwnProperty.call(config.environments ?? {}, name)\n}","tryCatchPattern":null,"preventionTips":["Declare every environment name under config.environments before use.","Match casing between config keys and constructor arguments.","Remove construction code when you remove an environment."],"tags":["environments","config","dev-server","api-misuse"],"backgroundTag":null,"analyzedSha":"b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab","analyzedAt":"2026-08-11T11:49:19.515Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}