forum subscription

Wanna help programmers by answering latest Angular questions?

We will email you whenever a new question is posted in Angular section. Max 2 emails per week.

Migration of Angular 4 project to Angular 5

  1. What are the major differences in Angular 4 and Angular 5?
  2. How much effort will be required for migrating Angular 4 project to Angular 5
  3. Is there any official documentation available for migration from Angular 4 to Angular 5

Sachin Magar 9 months ago
  • Saumya Rastogi

    Answering for point 1

    The new Angular 5 has a very minimal change as compared to Angular 4.
    Some of the changes are listed below:

    1. Build Optimizer: This is a tool which was included in the CLI to help the developers in creating a smaller bundle for the application. Apart from decreasing the user's bundle size, the feature also helps in increasing the boot speed of the application for the users.

    2. Compiler Improvements: To enhance faster rebuilds for production and AOT (Ahead of Time) builds, Angular 5 supports incremental compilation.

    3. New Router Lifecycle Events: This new feature was added to enable the developers in tracking the cycle of the router, starting from running guards to the completion of activation. This would be the major change, but not the breaking change for Angular 4 projects.

    4. HttpClient: This feature has been recommended for all the application as HTTPClient was highly appreciated. The framework developer are not suggesting anymore, to use the previous @angular/http library.

    Answering for point 2

    In terms of effort, it doesn't require a huge effort, don't worry!

    Answering for point 3

    To migrate from Angular 4 to Angular 5, you need to update all angular provided packages to their latest versions as follows:

    npm install typescript@2.4 --save-dev
    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 --save

    This should do all the necessary stuffs for you, and you could also update to newer version of Angular CLI which ships with Angular 5. You can do that by the following commands:

    npm uninstall -g @angular/cli
    npm cache clean
    npm install -g @angular/cli@latest

    Finally, I recommend you to have a look at Angular Update Guide, which is an official guide for angular migrations.