Reputation: 3790
I've recently been working on a small project in VS Code that is primarily typescript.
I committed it to a GitHub repository and downloaded it onto a machine that I regularly use for TypeScript development. However, when I try to build my VS Code project, I get the error:
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
+ ~~~
+ CategoryInfo : ObjectNotFound: (tsc:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
After reading other StackOverflow questions on the subject, I tried a few things:
npm install -g typescript
- I received no error messages, so it seems the install was successful (confirmed in Step 3).tsc
compiler. I found none.npm list -g
to ensure that TypeScript installed (it did.)C:\Users\MyUserName\AppData\Roaming\npm\tsc
- the path rantsc -v
- command was not recognized by the OS.setx path "%paths%:C:\MyUserName\AppData\Roaming\npm"
to try to add the npm global directory to the system environment paths
variable. Upon running the command, closed the command line, opened a new one, and tried an unqualified tsc
command. No luck.It's almost as if the npm install -g typescript
command isn't enough to actually install TypeScript such that the system recognizes it on a global basis (despite using the -g/"global" flag). Clearly I'm missing something. What is it that I'm missing?
Upvotes: 0
Views: 1864
Reputation: 1
Try running npx tsc -v
;
It should print the typescript version.
Once you get that if you want run an .ts file run using the command npx tsc filename.ts
.
It should work.
Upvotes: 0
Reputation: 3790
After updating node.js to 10.13.0 LTS, after closing and re-opening both my command prompt and VS Code, tsc
runs.
So, be sure you update node if you start getting funny feedback from tsc!
Upvotes: 2