We have seen how to install the Angular CLI in this blog.
But in this article, you will learn how to update the Angular CLI which is already installed on your machine.
You can update any library and in any sequence:
- Download and Re-Install Node.js.
- Update npm
- Update TypeScript
- Update Angular CLI
Remember to update Angular CLI, it is not mandatory to update Node or npm or Typescript.
Step 1: Download and Re-Install Node.js
Go to the Node.js main website – https://nodejs.org/en/ and download the stable version of Node and install on your local machine.
If you already have Node.js then uninstall it first and then reinstall the new version.
Step 2: Update npm
After you have completed updating the Node on your machine. Then next step is to update the npm
$ npm cache clean
$ npm install npm@latest -g
Verify Node is installed properly:
$ node -v
$ node -help
Verify npm is installed properly:
$ npm -version
$ npm -help
You get npm by default when you install Node.js installer. With the -help command line argument you can learn more about the additional arguments that you can pass to the node and npm.
Step 3: Update Typescript
Update and Verify Typescript:
$ npm install –g typescript@latest
$ tsc -version
$ tsc -help
-g option means that you are installing this package globally and it can accessed from anywhere.
Step 4: Update Angular CLI
After you have updated all the above dependencies then you can update Angular CLI using npm.
Update and Verify Angular CLI:
$ npm uninstall -g angular-cli @angular/cli
$ npm cache clean --force
$ npm install -g @angular/cli@latest
$ ng --version
$ ng --help
Now you can verify the version numbers before and after installation to see if the libraries are updated properly.