73

So i did ng -v it shows me everything except typescript, so how can i check Typescript version of my angular 4 project.

RajnishCoder
  • 3,455
  • 6
  • 20
  • 35

8 Answers8

103

Open package.json file and check devDependencies node. It has typescript version used in project like below.

"typescript": "^2.4.0",

You can also use command prompt as Sajeetharan suggested in below answer.

Karan Patel
  • 2,219
  • 3
  • 19
  • 32
  • 1
    Great.. let me know if you need any help.. You should mark answer as accepted if you find helpful. – Karan Patel Oct 17 '17 at 06:51
  • 6
    although keep in mind the caret in ^2.4.0 means you could be getting 2.5.x 2.6.x, etc. It tells you the minor version will automatically be updated to the latest version upon a fresh install (or an npm update) – Michael Kang Oct 17 '17 at 07:12
  • 1
    It's wrong to me, it doesn't give the actual version since you use a caret see https://stackoverflow.com/questions/22343224/whats-the-difference-between-tilde-and-caret-in-package-json The only reliable way to get the version as indicated in another answer is to check the resolved version not the asked version – pdem Oct 31 '19 at 11:22
52

If you want the exact version installed as a package dependency use the ls command:

npm ls typescript

Alternatively, you could run tsc with the -v flag:

If installed locally:

node_modules\.bin\tsc -v

If installed globally:

tsc -v

NOTE: If you plan on checking package.json for the version number, keep in mind the caret in ^2.4.0 means you could be getting 2.4.x, 2.5.x 2.6.x, etc. The ^ tells you the minor version will automatically be updated to the latest version upon a fresh install or an npm update.

If the version number is preceeded by ~ (i.e. ~2.4.0), then the patch number is automatically updated on a new install or update. That means any of the following versions could be installed: 2.4.0, 2.4.1, 2.4.2, etc, but not 2.5.x

Michael Kang
  • 52,003
  • 16
  • 103
  • 135
  • in side `node_modules\.bin` it shows The program 'tsc' is currently not installed. You can install it by typing: sudo apt install node-typescript. show me same for globally i have ubuntu – RajnishCoder Oct 17 '17 at 06:45
  • to install it locally: `npm install typescript --save-dev`. To install it globally: `npm install -g typescript` – Michael Kang Oct 17 '17 at 06:48
  • Instead of `node_modules\.bin\tsc -v`, what about `npx tsc -v` ? – Romain Deneau Aug 22 '19 at 07:53
15

Open command prompt , to check the globally installed version,

Type

tsc -v

and hit Enter

to check particular project version, navigate to node_modules\.bin\

./tsc -v

another way is to check the package.json inside the project folder

{
  "name": "angular-quickstart",
  "version": "1.0.0",
  "description": "QuickStart package.json from the documentation, supplemented with testing support",
  "scripts": {},
  "keywords": [],
  "license": "MIT",
  "dependencies": {},
  "devDependencies": {
    "tslint": "^4.0.2",
    "typescript": "~2.1.5"
  },
  "repository": {}
}
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
  • 2
    That will tell the version of the globally installed TypeScript compiler. Not the version used by angular-cli for that particular project. – JB Nizet Oct 17 '17 at 06:41
  • @JBNizet yes right! usually we instlal typescript globallly – Sajeetharan Oct 17 '17 at 06:42
  • That will still tell the version of the globally installed tsc. You would need `./tsc -v` to be sure you're executing the local one. – JB Nizet Oct 17 '17 at 06:45
  • 6
    *usually we instlal typescript globallly*: but angular-cli never uses your globally installed version. It uses the one specified in the devDependencies section of the package.json file of the project. – JB Nizet Oct 17 '17 at 06:46
8

To know the version of Typescript, use:

ng v

This will out put the typescript version and other dependence versions as well. Mine show as bellow:

@angular-devkit/architect         0.7.1
@angular-devkit/build-angular     0.7.1
@angular-devkit/build-optimizer   0.7.1
@angular-devkit/build-webpack     0.7.1
@angular-devkit/core              0.7.1
@angular-devkit/schematics        0.7.1
@angular/cli                      6.1.1
@ngtools/webpack                  6.1.1
@schematics/angular               0.7.1
@schematics/update                0.7.1
rxjs                              6.2.2
typescript                        2.7.2
webpack                           4.9.2
Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
Aman
  • 167
  • 2
  • 1
  • 1
    This is what the OP tried to do and it didn't work. Could you please expand on alternatives if this doesn't work? – Auden Young Jul 31 '18 at 15:21
  • If `ng -v` didn't work, then it is probably that typescript is not installed. So install typescript as follows: `npm install -g typescript` for more information see the linke [https://www.npmjs.com/package/typescript] – Aman Aug 01 '18 at 21:22
  • 5
    ng v is the command, not -v. This also just reports what is installed, not what is working with a particular Angular version. – Steven Scott Apr 09 '19 at 18:16
7

In my ubuntu 18.04 LTS with angular 7 cli installed, I typed

ng v

and it gave the output:

Node: 11.8.0
OS: linux x64
Angular: 7.2.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.12.3
@angular-devkit/build-angular     0.12.3
@angular-devkit/build-optimizer   0.12.3
@angular-devkit/build-webpack     0.12.3
@angular-devkit/core              7.2.3
@angular-devkit/schematics        7.2.3
@angular/cli                      7.2.3
@ngtools/webpack                  7.2.3
@schematics/angular               7.2.3
@schematics/update                0.12.3
rxjs                              6.3.3
typescript                        3.2.4
webpack                           4.28.4
AlWong
  • 71
  • 1
  • 1
4

Just type on terminal:

npm ls typescript
1

Simple answer using yarn (since other answer were using npm)

This will list the dependencies using yarn then filter only typescript

yarn list --pattern typescript

Or you can simply check the content of yarn.lock file (equivalent of package-lock.json)

grep "typescript" yarn.lock
pdem
  • 3,880
  • 1
  • 24
  • 38
0

To know the typescript version which is installed on my machine, use this command in command prompt.

tsc --version

Sheo Dayal Singh
  • 1,591
  • 19
  • 11