【问题标题】:TypeScript install/version error: The term 'tsc' is not recognizedTypeScript 安装/版本错误:无法识别术语“tsc”
【发布时间】:2017-12-01 03:27:04
【问题描述】:

在新计算机上设置项目并遇到 TypeScript 版本控制问题。我试过了:

npm install -g typescript
npm install typescript
npm install -g typescript@2.1.6
npm install -g typescript@2.0.10

但每次我尝试使用以下方式检查版本时:

tsc -v

我收到以下错误:

The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path wa
s included, verify that the path is correct and try again.
At line:1 char:4
+ tsc <<<<  -v
    + CategoryInfo          : ObjectNotFound: (tsc:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException 

供参考,package.json 包括:

"scripts": {
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings",
    "gulp": "gulp",
    "build-dev": "gulp",
  },
"devDependencies": {
    "gulp": "^3.9.1",
    "gulp-concat": "^2.6.0",
    "gulp-inline-ng2-template": "^4.0.0",
    "gulp-typescript": "^3.0.2",
    "path": "^0.12.7",
    "systemjs-builder": "^0.15.26",
    "typescript": "^2.1.6",
    "typings": "^2.0.0"
  }

当我在我的机器上运行 tsc -v(它正在工作)时,我得到了

Version 2.0.10

坚持我需要做些什么来安装 TypeScript 以便识别 tsc 命令?

【问题讨论】:

    标签: typescript installation version


    【解决方案1】:

    如果此问题来自您的命令外壳。 首先安装最新的 npm 版本,然后再次尝试安装 TypeScript。

    如果您在运行 tsc build 任务时使用 VS CODE 进行开发并在 VS 代码终端中发出问题:如果您从 Visual Studio 2015/2017 安装了 TypeScript 并且路径位于环境变量中,则首先将其删除。然后重新启动并重试。

    我遇到了和你一样的问题,我通过上面的步骤解决了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-14
      • 2020-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多