使用Visual Studio代码执行Typescript文件

时间:2017-10-06 13:53:37

标签: typescript visual-studio-code

我在执行打字稿文件时遇到了一些麻烦。我正在使用visual studio代码来执行typescript文件。我已经安装并设置了visual studio代码和打字稿。但是当我尝试执行typescript文件(tsc filename.ts)时,它显示错误。请帮忙!

错误:

PS D:\01_Hello> tsc app.ts
tsc : 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 was included, verify that the path is correct and try again.
At line:1 char:1
+ tsc app.ts
+ ~~~
    + CategoryInfo          : ObjectNotFound: (tsc:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

2 个答案:

答案 0 :(得分:1)

Visual Studio Code旨在使用您通过NPM获取的TypeScript版本。所以这是你需要做的步骤......

  1. 安装节点
  2. 运行npm install -g typescript
  3. 检查它是否适用于tsc -v
  4. 你现在应该把一切都搞定了。

答案 1 :(得分:1)

  1. https://nodejs.org/en/

  2. 安装节点js
  3. 从安装nodejs的路径中打开cmd并运行npm install -g typescript

  4. 现在转到cmd上app.ts所在的位置并运行tsc app.ts