Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's wrong with my typescript compiler? `tsc --version` returns nothing

In Linux Mint, I've installed node and used it to install typescript. With a working typescript installation, tsc --version should return the version number. In my case, nothing is returned at all.

When I run which tsc the result is /usr/local/bin/tsc.

When I run cat /usr/local/bin/tsc the result is:

#!/usr/bin/env node
require('../lib/tsc.js')

When I run find /usr/local -name 'tsc*' the result is:

/usr/local/bin/tsc
/usr/local/lib/node_modules/typescript/bin/tsc
/usr/local/lib/node_modules/typescript/lib/tsc.js

Does that look correct? If so, then any ideas on what else to look at would be appreciated?

Note I also tried running /usr/local/lib/node_modules/typescript/bin/tsc --version and got the same result ie nothing.

like image 340
Highly Irregular Avatar asked Sep 29 '15 03:09

Highly Irregular


People also ask

Why is tsc not working?

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!

How do I fix tsc not recognized?

To solve the error "tsc is not recognized as an internal or external command, operable program or batch file", install typescript globally by running npm install typescript@latest -g or prefix tsc with npx , e.g. npx --package typescript tsc --init .

What does tsc do in TypeScript?

Tsc stands for `TypeScript compiler` and is a simple tool included in Typescript itself, allowing you to compile any ts files into js.


1 Answers

In my case on Ubuntu 16.04 the problem was because of I performed sudo apt-get install node-typescript, which delivered me broken tsc. After removing it via apt-get remove and then installing as recommended with npm install -g typescript, it worked fine.

Maybe this will help someone.

like image 156
Nikita Ivanov Avatar answered Nov 15 '22 22:11

Nikita Ivanov