Angular 8 errors on start up

301 views Asked by At

When i start angular app with "ng serve" command, I see the below errors in the chrome developer tools console:

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
2

There are 2 answers

1
Muthupriya On

You have to provide some logic in main.ts to prevent this issue.

Add the below code to your main.ts file.

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));

0
MatterOfFact On

The error message is caused by the Kaspersky Password Manager Browser Extension. After deactivating the extension in my browser, the error message disappeared.

In my case, the error message had nothing to do with my Angular application