Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't find Typescript compiler: Command "tsc" is not valid

Just installed Typescript extension to VS2012 and followed Install TypeScript for Visual Studio 2012 and then the tutorial to call the compiler:

> tsc greeter.ts 

But when i try to compile .ts file where should i type: tsc greeter.ts? Tried it in VS command line and in windows console, always get the message that tsc is not recognized as command(Command "tsc" is not valid.).

like image 427
0x49D1 Avatar asked Oct 02 '12 07:10

0x49D1


People also ask

How do I get tsc TypeScript?

TypeScript is available as a package on the npm registry available as "typescript" . You will need a copy of Node. js as an environment to run the package. Then you use a dependency manager like npm, yarn or pnpm to download TypeScript into your project.

Why is tsc not found?

To solve the error "tsc: command not found", install the typescript package globally by running npm install typescript@latest -g or use the npx command with the --package flag, e.g. npx --package typescript tsc --init . The fastest way to solve the error is to use the npx command with the --package flag. Copied!

What is tsc command in TypeScript?

Running tsc locally will compile the closest project defined by a tsconfig. json , you can compile a set of TypeScript files by passing in a glob of files you want.

How do I run tsc TypeScript?

We can use the ts-node package to execute TypeScript files from the command line. Install it with npm or other package manager. After that, simply execute the TypeScript files with the command: ts-node filename.


1 Answers

If you're using tsc as a node module, make sure you've installed it with

npm install -g typescript 

Then it should be available globally in your node command prompt

like image 167
lhk Avatar answered Sep 20 '22 04:09

lhk