Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrating Angular 4.x to Angular 5 [duplicate]

I have read the following blogs and documentation

  • Angular Blog
  • Alligator IO Docs
  • Official Documentation

and no clear information about how to migrate from 4.x to 5.

Tried the following commands

  • npm install

    npm install @angular/{animations,common,compiler,compiler-cli,
                core,forms,http,platform-browser,platform-browser-dynamic,
                platform-server,router}@5.0.0
    
  • yarn installation

    yarn add @angular/{animations,common,compiler,compiler-cli,
             core,forms,http,platform-browser,platform-browser-dynamic,
             platform-server,router}@5.0.0
    
  • Tried the update guide

     npm install @angular/animations@'^5.0.0' @angular/common@'^5.0.0' 
            @angular/compiler@'^5.0.0' @angular/compiler-cli@'^5.0.0' 
            @angular/core@'^5.0.0' @angular/forms@'^5.0.0'
            @angular/http@'^5.0.0' @angular/platform-browser@'^5.0.0' 
            @angular/platform-browser-dynamic@'^5.0.0' 
            @angular/platform-server@'^5.0.0' @angular/router@'^5.0.0' 
            [email protected] rxjs@'^5.5.2'
    
     npm install [email protected] --save-exact
    

Nothing worked fine for me. Please help

like image 813
Aravind Avatar asked Nov 03 '17 20:11

Aravind


2 Answers

You need to update all angular provided packages to their latest versions as follows:

npm install [email protected] --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. Plus you could also update your angular cli that ships with angular 5 as standard version as follows:

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

Here is the official blogpost by Angular team : https://angular-update-guide.firebaseapp.com/. This update guide will help you to migrate from any version to the latest one.

like image 87
Peter Avatar answered Nov 12 '22 01:11

Peter


This website made it very easy for me. Put in your version you're upgrading from, and which one you're upgrading to. My app is simple, so it may depend on the complexity of your app.

like image 5
Ben Avatar answered Nov 12 '22 02:11

Ben