1

I m using the asp.net core 2.0 AngularJS template and When I trying to use localStorage in AppComponent it’s says

NodeInvocationException: localStorage is not defined ReferenceError: localStorage is not defined.

I waste much time to fixed this, unfortunately angular2-universal even not working with the asp.net core 2.0 to check the condition isBrowser. Event the localStorage does not working with HomeComponent also.

How can I fixed this. Please help me to fixed this. Thank you.

export class AppComponent {

constructor() {

    localStorage.setItem('count', 'not set');
    console.log('const');
}

}

  • See if these help: https://stackoverflow.com/questions/39085632/localstorage-is-not-defined-angular-universal and https://stackoverflow.com/questions/46072312/referenceerror-localstorage-is-not-defined – TheChetan Sep 28 '17 at 13:14
  • This is not fixed the my problem. actually I can use the localStorage in CounterComponent and FetchDataComponent. It's only happen with HomeComponent and AppComponent with my template. – Eranga Ananda Sep 28 '17 at 13:41
  • I have a similar issue. I commented out all the local storage code and ran the web app again and then I got a different error. `NodeInvocationException: The Node invocation timed out after 60000ms. You can change the timeout duration by setting the InvocationTimeoutMilliseconds property on NodeServicesOptions. The first debugging step is to ensure that your Node.js function always invokes the supplied callback (or throws an exception synchronously), even if it encounters an error. Otherwise, the .NET code has no way to know that it is finished or has failed.` – TheMagnificent11 Dec 07 '17 at 15:03

1 Answers1

0

It seems someone posted a similar question on Github (https://github.com/MarkPieszak/aspnetcore-angular2-universal/issues/238).

I think there is an Angular error somewhere but it's getting reported as something else because the VS Angular template uses Webpack to build the Angular app. I think the Webpack app is failing to build and the underlying issue is not reporting by ASP.Net Core.

TheMagnificent11
  • 1,424
  • 4
  • 19
  • 40