【问题标题】:Angular 8 errors on start up启动时出现 Angular 8 错误
【发布时间】:2020-12-18 05:57:44
【问题描述】:

当我使用“ng serve”命令启动 Angular 应用程序时,我在 chrome 开发人员工具控制台中看到以下错误:

Angular is running in the development mode. Call enableProdMode() to enable the production mode.
index.js:7 Error: Invalid value type
    at Function.a.set (index.js:7)
    at t.setIsTrutedEnforced (index.js:7)
    at index.js:49
a.set @ index.js:7
t.setIsTrutedEnforced @ index.js:7
(anonymous) @ index.js:49
Promise.then (async)
h @ index.js:49
(anonymous) @ index.js:49
(anonymous) @ index.js:7
n @ index.js:49
index.js:7 Uncaught (in promise) Error: Given action "NormalMode/SetPageData", reducer "isTrustedEnforced" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.
    at index.js:7
    at Object.g [as dispatch] (index.js:7)
    at t.SetPageData (index.js:7)
    at index.js:49

【问题讨论】:

  • 此处与边缘和角度 10 相同
  • Chrome 也出现此错误。有什么想法吗?

标签: node.js angular typescript nodes angular8


【解决方案1】:

您必须在 ma​​in.ts 中提供一些逻辑来防止此问题。

将以下代码添加到您的 ma​​in.ts 文件中。

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule)
  .catch(err => console.error(err));

【讨论】:

  • 与边缘相同
【解决方案2】:

错误消息是由 Kaspersky Password Manager 浏览器扩展引起的。在我的浏览器中停用扩展程序后,错误消息消失了。

就我而言,错误消息与我的 Angular 应用程序无关

【讨论】:

    猜你喜欢
    • 2021-07-21
    • 2012-09-23
    • 2021-12-14
    • 2013-09-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-18
    • 1970-01-01
    • 2011-05-25
    相关资源
    最近更新 更多