How do I correctly upgrade angular 2 (npm) to the latest version?

The command npm update -D && npm update -S will update all packages inside package.json to their latest version, according to their defined version range. You can read more about it here.

If you want to update Angular from a version prior to 2.0.0-rc.1, then you’ll need to manually edit package.json, as Angular was split into several npm modules. Without this, as angular2 package points to 2.0.0-beta.21, you’ll never get to use the latest version of Angular.

A list with some of the most common modules that you’ll need to get started can be found in the quickstart repository.

Notes:

  • A cool way to stay up to date with your packages’ latest version is to use npm outdated which shows you all outdated packages together with their wanted and latest version.

  • The reason why we need to chain two commands, npm update -D and npm update -S is to overcome this bug until it’s fixed.

Leave a Comment