Updating Angular CLI and Upgrading Existing Projects -- Words (436)

update Angular CLI and Projects

In this short guide we'll see how to update Angular CLI to the latest version, 1.2.5 when writing this. And also how to upgrade existing Angular 2+ projects to use the latest Angular dependencies.

To install Angular CLI, you just need to open your terminal or command prompt then run:

npm install -g @angular/cli 

It's clearly obvious that you need Node.js and NPM installed on your system to be able to install and run Angular CLI.

Updating Angular CLI

If you have an existing Angular CLI version installed and want to update it, you can remove it first using the following:

    npm uninstall -g angular-cli
    npm cache clean    

Then re-install it again with:

npm install -g @angular/cli 

Upgrading Existing Angular 2+ Projects

Now how about existing Angular 2+ projects, generated using the Angular CLI?

You can easily update them to use latest dependencies by following these instructions:

First check your versions of installed Angular CLI and other dependencies with:

ng --version 

In my case I'm getting this output:

@angular/cli: 1.0.0
node: 7.9.0
os: linux ia32
@angular/animations: 4.1.2
@angular/common: 4.1.2
@angular/compiler: 4.1.2
@angular/core: 4.1.2
@angular/forms: 4.1.2
@angular/http: 4.1.2
@angular/platform-browser: 4.1.2
@angular/platform-browser-dynamic: 4.1.2
@angular/platform-server: 4.1.2
@angular/router: 4.1.2
@angular/cli: 1.0.0
@angular/compiler-cli: 4.1.2

Since we have installed the latest Angular CLI globally, If you try to serve your project you'll be getting a warning of version mismatch:

Your global Angular CLI version (1.2.5) is greater than your local
version (1.0.0). The local Angular CLI version is used.
To disable this warning use "ng set --global warnings.versionMismatch=false".

Next open your project package.json file then change the Angular CLI version: you can check the npm info page for Angular CLI package from this link to find out the latest version.

"@angular/cli": "1.2.5"

Next delete your project node_modules folder and run npm install:

npm install

P.S. You don't need to change the versions of the other dependencies, the Angular CLI will take care of fetching latest versions.

Now you can check again for installed versions with:

ng --version 

In my case I'm getting this output:

@angular/cli: 1.2.5
node: 7.9.0
os: linux ia32
@angular/animations: 4.3.1
@angular/common: 4.3.1
@angular/compiler: 4.3.1
@angular/core: 4.3.1
@angular/forms: 4.3.1
@angular/http: 4.3.1
@angular/platform-browser: 4.3.1
@angular/platform-browser-dynamic: 4.3.1
@angular/platform-server: 4.3.1
@angular/router: 4.3.1
@angular/cli: 1.2.5
@angular/compiler-cli: 4.3.1

As you can see Angular 4.3.1 is installed.

mrnerd is a Web Entrepreneur & Developer, Digital Marketer and a Passionate Blogger. He writes about software and website development,money making tips and SEO etc.. He is a tech addict and a computer geek with a lot of hobbies.