首页 文章

使用Visual Studio代码执行Typescript文件

提问于
浏览
-1

我在执行打字稿文件时遇到了一些麻烦 . 我正在使用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 回答

  • 1

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

    • 安装节点

    • 运行 npm install -g typescript

    • 检查它是否适用于 tsc -v

    你现在应该把一切都搞定了 .

  • 0
    • https://nodejs.org/en/安装节点js

    • 从安装了nodejs的路径打开cmd并运行 npm install -g typescript

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

相关问题