How to Check which version of TypeScript is installed

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
3 min

banner

# How to Check which version of TypeScript is installed

Use the npm ls typescript command to check which version of typescript is installed locally in your project.

If you need to check the globally installed version of typescript, use the npm ls -g typescript command.

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 typescript

npm check local version of typescript

The screenshot shows that my version of typescript is 4.7.4.

You can check the version of typescript without its dependencies by setting the --depth argument to 0.

shell
npm ls typescript --depth=0

npm check local version of typescript without dependencies

# Checking your globally installed TypeScript version

If you need to check the version of a globally installed typescript package, use the npm ls -g typescript command.

shell
# ๐Ÿ‘‡๏ธ check which version of `typescript` is installed globally npm ls -g typescript # ๐Ÿ‘‡๏ธ list the versions of all globally installed packages npm ls -g

npm check global version of typescript

# Using the tsc command to check your TypeScript version

You can also use the TypeScript CLI (tsc) to check the globally installed version of TypeScript.

shell
tsc -v

tsc check global version of typescript

# Checking the TypeScript version in your package.json file

You can also check the version of your locally installed typescript package in the dependencies or devDependencies object in your package.json file.

package json check installed version of typescript

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

shell
# ๐Ÿ‘‡๏ธ install `typescript` npm install typescript --save-dev # ๐Ÿ‘‡๏ธ install the latest version of TypeScript npm install typescript@latest --save-dev

If you need to install typescript globally, run the following command.

shell
# ๐Ÿ‘‡๏ธ install typescript globally npm install -g typescript # ๐Ÿ‘‡๏ธ install the latest version of typescript globally npm install -g typescript@latest

You can use the tsc -v command to verify that typescript has been installed.

shell
tsc -v

tsc check global version of typescript

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

If you need to get the latest version of typescript, use the npm view typescript version command.

shell
npm view typescript version

typescript get latest version

# List all available versions of the TypeScript module

If you want to list all versions of the typescript package, use the npm view typescript versions command.

shell
npm view typescript versions npm view typescript versions --json

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

shell
# ๐Ÿ‘‡๏ธ locally npm install typescript@4.9.3 --save-dev # ๐Ÿ‘‡๏ธ globally npm install -g typescript@4.9.3

If you need to update typescript to the latest version, use the following command.

shell
# ๐Ÿ‘‡๏ธ update the locally installed `typescript` package to the latest version npm install typescript@latest --save-dev # ๐Ÿ‘‡๏ธ update the globally installed `typescript` package to the latest version npm install -g typescript@latest
To update the globally installed typescript 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.

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