How to update Angular
How to update Angular to the latest version
The goal of this post is to show how to update Angular in your development environment, this post doesn't cover the update of a specific project.
To update the version of Angular on your machine you can follow the following steps.
Verify the version of Angular installed
To check the version of Angular installed you can execute:
npm list -g @angular/clithis is a function of npm that shows the information about a package, we use the parameter -g assuming that you want to update the global installation of Angular and not a project specific one.
If Angular is installed on your system you should see an answer like:
/Users/marco/.nvm/versions/node/v20.10.0/lib
└── @angular/cli@17.1.1This means that we are using node version 20 and Angular version 17.1.1 With Angular for the update we work mainly with the cli project.
List of the Angular versions available
Before to update your local version you can check in the Terminal which versions are available on npm:
npm view -g @angular/cli dist-tagsThis command should show us something similar to:
{
latest: '17.3.3',
next: '18.0.0-next.2',
'v6-lts': '6.2.9',
'v8-lts': '8.3.29',
'v7-lts': '7.3.10',
'v9-lts': '9.1.15',
'v10-lts': '10.2.4',
'v11-lts': '11.2.19',
'v12-lts': '12.2.18',
'v13-lts': '13.3.11',
'v14-lts': '14.2.13',
'v15-lts': '15.2.11',
'v16-lts': '16.2.13'
}These are the official releases of Angular. You can notice that are listed the lts versions, the current / latest, and the next version, that has yet to be released.
In our example we will install the next version because we want to test some new features.
Uninstall the current version of Angular
npm uninstall -g @angular/cliRemember to uninstall the -g global version of Angular. The result should be similar to:
removed 235 packages in 729msInstall a new version of Angular
Now you can install the version that you prefer. In our case we opted to install the version in development:
npm install -g @angular/cli@nextThe result should be similar to:
added 233 packages in 2s
44 packages are looking for fundingIt's possible to have some warnings from npm if some dependencies don't match, you should not worry about. In case of errors, read the information and updated the required libraries.
To install the latest version we could have used:
npm install -g @angular/cli@latest