Mostefai Mohammed Amine

Software and Cloud Architect

Amine
  • Contact
Previous Post
Next Post
Sep 24, 2016 Angular

No provider for “SER” after Angular 2 Upgrade

 

Certainly, after upgrading Angular 2 to the latest version (starting from RC6), you’ll probably encounter one of the following errors:

· “No provider for service XXX”

· The component “CCC” does not to module “MMM”

A little troubleshooting will indicate that the related files are loaded twice knowing that everything worked just fine before the update.

The clue is that the new version of Angular 2 does take in consideration the difference between lowercase and uppercase later in type script import statements.

Hence, the two following statements:

import {SER} from “./services/ser.service”;

 

and

import {SER} from “./Services/ser.service”;

will be considered as two distinct paths by A2 and will cause the error.

The solution is quite simple, if you have such behavior, just analyze that the required file is not loaded twice and if so, locate the import statements that are different in the case sensitive sense.

Adopt as a best practice writing all your import statement using lowercase letters and centralizing your exports in a file to minimize the import statements.

upgraderouting
Share This Post

Related posts

  • Tutoriel 5.1 - Création d’un service de recrutement–Partie 2 Dans la partie précédente, nous avons créé les services et les workflows nécessaires à notre opérati...
  • No provider for “SER” after Angular 2 Upgrade   Certainly, after upgrading Angular 2 to the latest version (starting from RC6), you’ll probab...
  • Angular 2 + ASP.NET Core + SASS Starter Visual Studio 2015 Solution Hi, Angular 2 is a very promising framework and one of its biggest advantages is that it takes the p
Saving the comment

Cancel reply to comment

The captcha value you provided is incorrect.