How to check which version of Angular CLI is installed

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
4 min

banner

# Check which version of Angular CLI is installed

Use the ng version or ng v commands to check which version of Angular CLI is installed.

Alternatively, you can use the npm ls @angular/cli command to check the locally installed Angular CLI version and the npm ls -g @angular/cli to check the globally installed version.

shell
ng version # ๐Ÿ‘‡๏ธ same as above ng v

get angular version

If you use an older version of the Angular CLI, you would use the following commands.

shell
# ๐Ÿ‘‡๏ธ for older Angular CLI versions ๐Ÿ‘‡๏ธ ng --version ng -v

# Using the npm ls @angular/cli command to check your Angular CLI version

Alternatively, you can use the npm ls @angular/cli command to check your locally installed version of the Angular CLI.

Make sure to open your terminal in your project's root directory (where your package.json file is) before issuing the command.
shell
npm ls @angular/cli

check locally installed angular cli version

You can check the version of @angular/cli without its dependencies by setting the --depth argument to 0.

shell
npm ls @angular/cli --depth=0

check locally installed angular cli version no dependencies

If you need to check the version of a globally installed Angular CLI package, use the npm ls -g @angular/cli command.

shell
# ๐Ÿ‘‡๏ธ Check which version of `@angular/cli` is installed globally npm ls -g @angular/cli # ๐Ÿ‘‡๏ธ List the versions of all globally installed packages npm ls -g

check globally installed angular cli version

# Checking the version of your Angular packages in your package.json file

You can also check the version of your locally installed Angular packages in the dependencies and devDependencies objects in your package.json file.

check angular versions in package json

If you need to install @angular/cli locally to your project, open your terminal in your project's root directory and run the following command.

shell
# ๐Ÿ‘‡๏ธ install the Angular CLI npm install @angular/cli --save-dev # ๐Ÿ‘‡๏ธ install the latest version of `@angular/cli` npm install @angular/cli@latest --save-dev

If you need to install @angular/cli globally, run the following command.

shell
# ๐Ÿ‘‡๏ธ install `@angular/cli` globally npm install -g @angular/cli # ๐Ÿ‘‡๏ธ install the latest version of `@angular/cli` globally npm install -g @angular/cli@latest

Note that your locally installed version of the Angular CLI and the globally installed version have to match.

You can update your local and global Angular CLI versions to the latest with the following commands.

shell
# ๐Ÿ‘‡๏ธ update your local Angular CLI version npm install @angular/cli@latest --save-dev --legacy-peer-deps # ๐Ÿ‘‡๏ธ update the global Angular CLI version npm install -g @angular/cli@latest --legacy-peer-deps

If you need to check the versions of all locally installed packages, use the npm ls command without specifying a package name.

shell
npm ls # ๐Ÿ‘‡๏ธ list the versions of the installed packages without their dependencies npm ls --depth=0

list all angular local versions

If you need to get the latest version of the Angular CLI, use the npm view @angular/cli version command.

shell
npm view @angular/cli version

get latest version of angular cli

# List all available versions of the Angular CLI

If you want to list all versions of the @angular/cli package, use the npm view @angular/cli versions command.

shell
npm view @angular/cli versions npm view @angular/cli versions --json

If you want to install a specific version of @angular/cli, use the @ symbol to specify the version.

shell
# ๐Ÿ‘‡๏ธ locally npm install @angular/cli@15.0.2 --save-dev # ๐Ÿ‘‡๏ธ globally npm install -g @angular/cli@15.0.2

If you need to update @angular/cli to the latest version, use the following command.

shell
# ๐Ÿ‘‡๏ธ update the locally installed `@angular/cli` package to the latest version npm install @angular/cli@latest --save-dev # ๐Ÿ‘‡๏ธ update the globally installed `@angular/cli` package to the latest version npm install -g @angular/cli@latest
To update the globally installed @angular/cli package to the latest version, add the -g flag to the command.

You can use the npm outdated command to list the current version and the latest version of your npm packages.

shell
npm outdated

You can use the npm update command to update your locally installed packages or the npm update -g command to update your globally installed NPM packages.

shell
# ๐Ÿ‘‡๏ธ update ALL locally installed packages npm update # ๐Ÿ‘‡๏ธ update ALL globally installed packages npm update -g

The npm update command follows the version constraints specified in your package.json file.

If you want to update all packages in your project to the latest version, use the npm-check-updates package.

Open your terminal in your project's root directory (where your package.json file is) and run the following command.

You can add your package.json file to version control (e.g. git) because the following 2 commands will update the versions of your packages in your package.json file.
shell
npx npm-check-updates -u npm install --legacy-peer-deps

The commands update all package versions in your package.json file to the latest version and install the packages.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev