我在执行打字稿文件时遇到了一些麻烦。我正在使用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
答案 0 :(得分:1)
Visual Studio Code旨在使用您通过NPM获取的TypeScript版本。所以这是你需要做的步骤......
npm install -g typescript
tsc -v
你现在应该把一切都搞定了。
答案 1 :(得分:1)
从安装nodejs的路径中打开cmd并运行npm install -g typescript
现在转到cmd上app.ts所在的位置并运行tsc app.ts