SoFunction
Updated on 2025-04-04

Detailed explanation of the steps to smoothly upgrade Angular2 to Angular4

Preface

Angular4 finally released its official version two days ago, so how to upgrade it? In fact, Angular2 and Angular4 are in a smooth transition, not like the subversive rewrite of code between 1 and 2.

Angular4 is now releasedhttps:///article/

Why skip Angular 3?

According to Igor Minar, chief developer of Angular team: With the release of Angular 2, the Angular team introduced a semantic version control specification, that is, the semantic version is represented by three sets of numbers and arranged in the order, such as 2.3.1.

The Patch version is released every week, usually only fixes the problem and does not add new features. The Minor version is released every month, with some new features added, but not much changes compared to the old version. The Major version is released every six months, with some new features added and potentially some major changes.

The latest Angular router version number was 3.3.0, while the version number of other modules was 2.2.0. Since the version number was not synchronized, the team plans to synchronize it and directly use 4.0.0 as the new version number.

As the Angular team plans to release a major (Major) version every six months, Angular 5 will be released as planned in September 2017.

Upgrade process

Use npm-check to upgrade using the following command to check and press the space to select the package to upgrade

npm-check -u

Official recommendation

Upgrade cli

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

 rm -rf node_modules dist # use rmdir /S/Q node_modules dist in Windows Command Prompt; use rm -r -fo node_modules,dist in Windows PowerShell
 npm install --save-dev @angular/cli@latest

Upgrade package

 // linux/mac
 npm install @angular/{common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router,animations}@latest typescript@latest --save
 // Windows
 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 --save

Replace some other bags

 npm install @0.8.4 --save

Execute the installation command

 npm install

Summarize

The above is the entire content of this article. I hope the content of this article will be of some help to everyone’s study or work. If you have any questions, you can leave a message to communicate. Thank you for your support.

For more information about AngularJS, readers who are interested in view the topic of this site:Summary of AngularJS command operation skills》、《AngularJS Introduction and Advanced Tutorial"and"AngularJS MVC architecture summary》