---
title: "NUXT_B5033"
description: "schema 被直接赋给了运行时配置。"
canonical_url: "https://nuxt.zhcndoc.com/docs/4.x/errors/b5033"
---
# B5033

`nuxt.options.runtimeConfig` 中的某个值是 [schema](https://nuxt.zhcndoc.com/docs/4.x/guide/going-further/runtime-config#validating-with-a-schema)。加载配置时，以及模块调用 `updateRuntimeConfig()` 时，Nuxt 都会将 schema 替换为其默认值。直接赋给 `nuxt.options.runtimeConfig` 的 schema 不会被替换，因此读取该值的模块拿到的会是 schema 本身，而不是实际值。

## 解决方法

在模块中，请将 schema 传递给 [`updateRuntimeConfig()`](https://nuxt.zhcndoc.com/docs/4.x/api/kit/runtime-config#updateruntimeconfig)：

```ts [module.ts]
import { defineNuxtModule, updateRuntimeConfig } from '@nuxt/kit'
import { z } from 'zod'

export default defineNuxtModule({
  setup (_options, nuxt) {
    nuxt.options.runtimeConfig.myModule = z.object({ apiKey: z.string() }) // [!code --]
    updateRuntimeConfig({ myModule: z.object({ apiKey: z.string() }) }) // [!code ++]
  },
})
```

如果该模块不是你自己开发的，请向模块作者报告此问题。


## Sitemap

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