Upgrade from Angular 4 to 5: "NodeInvocationException: No Provider for PlatformRef!"

I updated the application from Angular from 4.2 to 5, but received this error:,   unhandled exception occurred while processing the requestor rather:

NodeInvocationException: no provider for PlatformRef! Error: no provider for PlatformRef! upon injection Error (E: \ MyApp \ ClientApp \ distance \ vendor.js: 12066: 90)

The application also uses webpack and ASP.NET Core.

I installed node v9.1and typescript 2.6.1.

I also updated package.jsonusing the command:

npm install @angular/common@latest @angular/compiler@latest @angular/compiler-cli@latest @angular/core@latest @angular/forms@latest @angular/http@latest @angular/platform-browser@latest @angular/platform-browser-dynamic@latest @angular/platform-server@latest @angular/router@latest @angular/animations@latest typescript@latest 

And after that they launched the following:

 npm install --save-dev @ngtools/webpack@latest

I also used HttpClientinstead Http:

import { HttpClient } from '@angular/common/http'; 
.....
 getThings() {
        return this.http.get('/api/things');

  }

If I go back to Angular 4, the application is working fine, is there something in my thought that was done wrong?

+4
2

: Angular 5 Asp Core

dependecies angular 5: npm install @angular/common@latest @angular/compiler@latest @angular/compiler-cli@latest @angular/core@latest @angular/forms@latest @angular/http@latest @angular/platform-browser@latest @angular/platform-browser-dynamic@latest @angular/platform-server@latest @angular/router@latest @angular/animations@latest typescript@latest

npm install --save-dev @ngtools/webpack@latest

webpack --config webpack.config.vendor.js ( webpack : npm install -g webpack@latest)

ClientApp/ASP Manully app.module:

import { HttpModule } from '@angular/http';

to

import { HttpClientModule } from '@angular/common/http';

Http HttpClient:

import { HttpClient } from '@angular/common/http'; 
+16

Source: https://habr.com/ru/post/1689208/


All Articles