Last updated: Apr 4, 2024
Reading timeยท4 min
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.
ng version # ๐๏ธ same as above ng v
If you use an older version of the Angular CLI, you would use the following commands.
# ๐๏ธ for older Angular CLI versions ๐๏ธ ng --version ng -v
npm ls @angular/cli
command to check your Angular CLI versionAlternatively, you can use the npm ls @angular/cli
command to check your
locally installed version of the Angular CLI.
package.json
file is) before issuing the command.npm ls @angular/cli
You can check the version of @angular/cli
without its dependencies by setting
the --depth
argument to 0
.
npm ls @angular/cli --depth=0
If you need to check the version of a globally installed Angular CLI package,
use the npm ls -g @angular/cli
command.
# ๐๏ธ 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
You can also check the version of your locally installed Angular packages in the
dependencies
and devDependencies
objects in your package.json
file.
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.
# ๐๏ธ 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.
# ๐๏ธ 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.
# ๐๏ธ 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.
npm ls # ๐๏ธ list the versions of the installed packages without their dependencies npm ls --depth=0
If you need to get the latest version of the Angular CLI, use the
npm view @angular/cli version
command.
npm view @angular/cli version
If you want to list all versions of the @angular/cli
package, use the
npm view @angular/cli versions
command.
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.
# ๐๏ธ 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.
# ๐๏ธ 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
@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.
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.
# ๐๏ธ 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.
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.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.
You can learn more about the related topics by checking out the following tutorials: