---
title: "NUXT_E8007"
description: "路由依赖客户端 JavaScript，但 noScripts 会在生产环境中移除脚本。"
canonical_url: "https://nuxt.zhcndoc.com/docs/4.x/errors/e8007"
---
# E8007

启用 `features.noScripts: 'production'` 时（启用 `noScripts` 时的默认值），脚本只会在生产构建中从渲染后的 HTML 中移除。在开发环境中，页面仍会提供 JavaScript，因此依赖它的行为（惰性 hydration 策略、服务器组件中的 `nuxt-client` 组件）在开发环境中看似正常，然后在部署后悄无声息地失效。

当渲染的路由使用其中一项功能时，此警告会在开发期间发出。

## 解决方案

可以从受影响的路由中移除客户端依赖，或者使用 `noScripts` 路由规则，将脚本移除范围限定为确实是静态的路由（该规则在开发环境中同样生效，因此任何问题都会立即显现）：

```ts [nuxt.config.ts]
export default defineNuxtConfig({
  routeRules: {
    '/static/**': { noScripts: true },
  },
})
```

或者，将 `features.noScripts: 'all'` 设置为在开发环境中也移除脚本，从而可以在开发环境中观察生产环境的行为。

::read-more{to="https://nuxt.zhcndoc.com/docs/4.x/guide/going-further/features#noscripts"}
::


## Sitemap

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