How to know which typescript version running on angular 4 project

后端 未结 7 627
梦谈多话
梦谈多话 2020-12-25 11:00

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

相关标签:
7条回答
  • 2020-12-25 11:25

    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
    
    0 讨论(0)
  • 2020-12-25 11:31

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

    tsc --version

    0 讨论(0)
  • 2020-12-25 11:33

    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.

    0 讨论(0)
  • 2020-12-25 11:35

    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
    
    0 讨论(0)
  • 2020-12-25 11:37

    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

    0 讨论(0)
  • 2020-12-25 11:47

    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": {}
    }
    
    0 讨论(0)
提交回复
热议问题