---
title: "NUXT_E8014"
description: "服务器启动时，运行时配置与 schema 不匹配。"
canonical_url: "https://nuxt.zhcndoc.com/docs/4.x/errors/e8014"
---
# E8014

服务器启动时，Nuxt 会将匹配的环境变量应用到[运行时配置](https://nuxt.zhcndoc.com/docs/4.x/guide/going-further/runtime-config)，并根据类型检查通过 schema 声明的值（或在 `compatibilityVersion: 5` 时检查所有值）。以下情况会导致服务器无法启动：

- 环境变量无法转换为其所覆盖值的类型（例如为 `z.number()` 类型的 `port` 设置 `NUXT_PORT=abc`）；
- [通过 schema 声明的值](https://nuxt.zhcndoc.com/docs/4.x/guide/going-further/runtime-config#validating-with-a-schema)为必填项，但没有默认值，也未通过环境变量设置；
- 值不在 schema 允许的取值范围内。

除非启用了 `compatibilityVersion: 5`，否则对于由模块通过 `updateRuntimeConfig()` 设置 schema 的值，只会报告警告，服务器会使用其默认值启动。

每条问题信息都会指出运行时配置键以及用于设置它的环境变量。

## 解决方法

请在服务器运行环境中，将列出的环境变量设置为有效值：

```bash [Terminal]
NUXT_API_SECRET=my-secret NUXT_PORT=8080 node .output/server/index.mjs
```

如果并非总是需要该值，请在 `nuxt.config` 中为其设置默认值或将其设为可选：

```ts [nuxt.config.ts]
import { z } from 'zod'

export default defineNuxtConfig({
  runtimeConfig: {
    apiSecret: z.string().optional(),
    port: z.number().default(3000),
  },
})
```

::read-more{to="https://nuxt.zhcndoc.com/docs/4.x/guide/going-further/runtime-config#environment-variables"}
::


## Sitemap

See the full [sitemap](https://nuxt.zhcndoc.com/sitemap.md) for all pages.
