alexgorbatchev

Tuesday, June 21, 2016

Angular 2 Exceptions: TypeError: Cannot read property 'annotations' of undefined

After playing with the newest incarnation of the Angular 2 Router (version 3.0.0-alpha.7) on a seperate test branch, I came back to my mainline branch and cleared my node_modules, build, tmp, and typings directories just to be safe. After reinstalling my npm modules (npm install), I received this gem, "TypeError: Cannot read property 'annotations' of undefined". Knowing that it was working prior to creating my test branch, and after some frustration examined the error a bit closer and saw that the html template causing the issue was related to the the routerLink directive, or more generally the Angular Router package. Digging into it a bit more I discovered that my npm semver for @angular/router-deprecated was "^2.0.0-rc.1" instead of "2.0.0-rc.1" and therefore was installing the Angular 2 RC-2 version of the deprecated router and was causing the error. After correcting the package, more specifcially the semver, for router-deprecated to 2.0.0-rc.1 and re-running npm install, all was well with the world.

The full exception is:


No comments:

Post a Comment