Install specific version of Angular CLI (How-to Guide)


Hey Angular friends! 👋

Today I'm going to show you how to install a specific version of the Angular CLI.

lagom-the-programmer-developes-code-at-his-laptop

The Angular CLI is an important tool for any type of Angular development.

It doesn't matter whether you are creating an Angular application or managing or refactoring an Angular project. Knowing which version of the Angular CLI to install can be crucial for compatibility.

As a rule of thumb, you should always be using the latest version of Angular and keep your projects up to date. But sometimes you get stuck on an older release waiting for library compatibility, etc...

So, how do you install a specific version of the Angular CLI?

Checking the available versions of Angular CLI

To check the available versions of Angular CLI, you can use npm, the package manager for Node. js. Open your command prompt or terminal and enter the following command:

npm show @angular/cli versions

This command will display a list of all available versions of Angular CLI.

npm-show-angular-versions

Look through the list to find the specific version you want to install.

If you prefer a visual interface, you can also visit the official Angular GitHub repository page and check their releases tab. This will provide a comprehensive list of all released versions with their respective release notes.

Once you have identified the version you want to install, proceed with downloading and installing it using the appropriate method discussed in subsequent sections.

Installing a specific version of Angular CLI using npm

Using npm to Install a Specific Version of Angular CLI

  1. First, open your command prompt or terminal.
  2. Next, enter the following command to install the specific version of Angular CLI that you want: npm install -g @angular/cli@<version>. Replace <version> with the desired version number, such as 17.0.1
  3. Wait for npm to download and install the specified version of Angular CLI on your system.

Verifying the Installation

  1. To verify that the installation was successful, run this command: ng version.
  2. If you see information about the installed Angular CLI version in your command prompt or terminal window, congratulations – you have successfully installed a specific version of Angular CLI using npm!

Troubleshooting common issues during the installation of a specific version of Angular CLI

Issue: "Invalid Peer Dependency"

  • When installing a specific version of Angular CLI, you might encounter an error message stating "Invalid peer dependency." This typically occurs when certain dependencies required by the specified version conflict with those already installed on your system.
  • To resolve this issue, it is recommended to update all relevant dependencies. Run the command npm outdated to check for outdated packages and then run npm update to update them.

Issue: "Permission Denied" or "EACCES"

  • If you see an error message saying "Permission denied" or "EACCES," it means that you don't have sufficient permissions to install packages globally on your system.
  • To fix this problem, you can either run the installation command with administrative privileges by using sudo (for Linux/macOS) or running Command Prompt as Administrator (for Windows).

Conclusion

And that, my friend, is how to install a specific version of Angular.

Till later,

signature

Daniel Kreider - Angular Developer

Credits

Illustration by Julia Buzatti from Ouch!