-1

I have some trouble executing a typescript file. I am using visual studio code to execute typescript files. I have installed and set up visual studio code and typescript. But when I try to execute typescript file (tsc filename.ts) it shows an error. Please help!

Error:

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
Murat Karagöz
  • 35,401
  • 16
  • 78
  • 107
einszweidrei
  • 27
  • 2
  • 6
  • Possible duplicate of [tsc is not recognized as internal or external command](https://stackoverflow.com/questions/35369501/tsc-is-not-recognized-as-internal-or-external-command) – ADreNaLiNe-DJ Oct 06 '17 at 13:55

2 Answers2

1

Visual Studio Code is designed to work with the version of TypeScript you've grabbed via NPM. So here are the steps you need to do...

  1. Install Node
  2. Run npm install -g typescript
  3. Check it worked with tsc -v

You should now have everything working.

Fenton
  • 241,084
  • 71
  • 387
  • 401
1
  1. install node js from https://nodejs.org/en/

  2. open cmd from the path where nodejs got installed and run npm install -g typescript

  3. now go to the location where app.ts is on cmd and run tsc app.ts

pushkin
  • 9,575
  • 15
  • 51
  • 95