Last updated: Apr 4, 2024
Reading timeยท3 min
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.
package.json
file is) before issuing the command.npm ls 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
.
npm ls typescript --depth=0
If you need to check the version of a globally installed typescript
package,
use the npm ls -g typescript
command.
# ๐๏ธ check which version of `typescript` is installed globally npm ls -g typescript # ๐๏ธ list the versions of all globally installed packages npm ls -g
tsc
command to check your TypeScript versionYou can also use the TypeScript CLI (tsc
) to check the globally installed
version of TypeScript.
tsc -v
package.json
fileYou can also check the version of your locally installed typescript
package in
the dependencies
or devDependencies
object in your package.json
file.
If you need to install typescript
locally to your project, open your terminal
in your project's root directory and run the following command.
# ๐๏ธ 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.
# ๐๏ธ 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.
tsc -v
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 typescript
, use the
npm view typescript version
command.
npm view typescript version
If you want to list all versions of the typescript
package, use the
npm view typescript versions
command.
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.
# ๐๏ธ 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.
# ๐๏ธ 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
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.
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.