TypeScript 安装/版本错误 : The term 'tsc' is not recognized

标签 typescript installation version

在新计算机上设置项目并遇到 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 命令?

最佳答案

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

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

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

关于TypeScript 安装/版本错误 : The term 'tsc' is not recognized,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44791062/

相关文章:

python - Boilerpipe-py3 的安装尝试给出 404 错误

javascript - typescript Electron 渲染器进程不工作

c++ - Boost库在ubuntu上产生错误

node.js - 我的命名空间未定义。 typescript

windows - Inno Setup - 从需要特权的安装程序访问非特权帐户文件夹

python - 安装了两个python(相同版本)

sql - Oracle中如何选择表中最后插入的记录

python - python 版本 x.y 和 x.y.z 之间有什么区别,例如 2.6 和 2.6.9?

javascript - 无需等待响应即可调用云函数

html - Angular Button 单击旋转图标