1

I'm using angular 4.2.4 in my application and I want to upgrade to the latest one (4.3.0)

is there an easy and safe way to do that without breaking my application ?

When searching I found this information from:

http://angularjs.blogspot.de/2017/07/angular-43-now-available.html

that link states that Angular 4.3 contains no breaking changes ?

I want to do that upgrade to use HttpClient

HDJEMAI
  • 9,436
  • 46
  • 67
  • 93

2 Answers2

2

I think you should be fine. Once you reference the new packages just make sure that your ng build --prod is not breaking.

If you want to use the new HttpClient you have change all parts of your code that referencing Http from @angular/http and replace that with HttpClient from @angular/common/http according with styleguide.

Also you have to change to all related .spec files that referencing old Http as well, then test with ng t, unless you does not care about tests.

If you are looking how upgrade all angular related packages more efficiently just look here How do I correctly upgrade angular 2 (npm) to the latest version?

angularrocks.com
  • 26,767
  • 13
  • 87
  • 104
  • Does `@angular/common/http` have backward compatibility? Can I use `Http` from `@angular/http` after updating my package from `@angular/common: 4.0.2` to `@angular/common: 4.3.0`? – Joseph Katzman Jan 16 '19 at 08:45
  • @JosephKatzman checkout this article https://medium.com/@amcdnl/the-new-http-client-in-angular-4-3-754bd3ff83a8 you have to adjust your code a bit as a new `http client` resolving your json now, so you do not have to do things like `result.json`, etc – angularrocks.com Jan 16 '19 at 08:48
  • Thanks for the article. I read it. Looks like there is no way to use `Http` from `@angular/http` after upgrading to `@angular/common: 4.3.0`. – Joseph Katzman Jan 16 '19 at 09:00
  • @JosephKatzman It is depends what version of angular you are upgrading to. It is definitely not available in the latest. They deprecate the old `http` but kept until version 5 as far for my memory. Then they didn't ship that with the latest angular versions. – angularrocks.com Jan 16 '19 at 09:03
0

You can use NPM command to update the installed all dependencies.

To update angular

npm install angular@version  (Provide version number) 

Example : npm install angular@4.3 

To download latest angular you can use npm install angular@latest

The command npm update -D && npm update -S will update all packages inside package.json to their latest version.

You can also apply the same command to update HttpClient as wells as all other dependencies

For my application I have upgraded from 4.2.4 to 4.3. Everything works fine. No more issues

Jameel Moideen
  • 7,542
  • 12
  • 51
  • 79