[typescript] 'tsc command not found' in compiling typescript

I want to install typescript, so I used the following command:

npm install -g typescript 

and test tsc --version, but it just show 'tsc command not found'. I have tried many ways as suggested in stackoverflow, github and other sites. but it doesn't work. How could I know typescript is installed and where it is.

my OS is Unix, OS X El Capitan 10.11.6, node version is 4.4.3, npm version is 3.10.5

This question is related to typescript npm tsc

The answer is


This works perfectly on Mac. Tested on macOS High Sierra

sudo npm install -g concurrently
sudo npm install -g lite-server
sudo npm install -g typescript
tsc --init

This generates the tsconfig.json file.


Non-admin solution

I do not have admin privileges since this machine was issued by my job.

  • get path of where node modules are being installed and copy to clipboard
    • npm config get prefix | clip
    • don't have clip? just copy output from npm config get prefix
  • add copied path to environment variables
    • my preferred method (Windows)
    • (Ctrl + R), paste rundll32 sysdm.cpl,EditEnvironmentVariables
    • under User Variables, double-click on Path > New > Paste copied path

I had to do this:

npx tsc app.ts

For windows:

Add the path by using command as below in command prompt:
path=%path%;C:\Users\\npm

As in my case, the above path was not registered for command.

%userprofile% in run windows, will give you path to C:\users\


I had this same problem on Ubuntu 19.10 LTS.

To solve this I ran the following command:

$ sudo apt install node-typescript

After that, I was able to use tsc.


The only solution that work for me was put npx tsc -v or for the compiling npx tsc salida.ts

"salida.ts" is the name of the file


This answer is specific for iTermV2 on MAC

  1. First of all, I needed to instal as sudo (admin) during NPM install

    sudo npm install -g typescript

  2. NPM installs the libraries under /usr/local/Cellar/node/<your latest version>/lib/node_modules/typescript folder and symlinks at /usr/local/Cellar/node/<your latest version>/bin/tsc

hence I went ~/.zshrc ( .bashrc, if you use bash)and added /usr/local/Cellar/node/<your latest version>/bin to the $PATH.

  1. reload the shell profile via source ~/.zshrc (.bashrc in your case)

If your TSC command is not found in MacOS after proper installation of TypeScript (using the following command: $ sudo npm install -g typescript, then ensure Node /bin path is added to the PATH variable in .bash_profile.

Open .bash_profile using terminal: $ open ~/.bash_profile;

Edit/Verify bash profile to include the following line (using your favorite text editor):

export PATH="$PATH:"/usr/local/lib/node_modules/node/bin"";

Load the latest bash profile using terminal: source ~/.bash_profile;

Lastly, try the command: $ tsc --version.


After finding all solutions for this small issue for macOS only.
Finally, I got my TSC works on my MacBook pro.

This might be the best solution I found out.

For all macOS users, instead of installing TypeScript using NPM, you can install TypeScript using homebrew.

brew install typescript

Please see attached screencap for reference. enter image description here


Easy fix for Mac I found. Just run these commands:

sudo npm install -g concurrently
sudo npm install -g lite-server
sudo npm install -g typescript

Nothing worked except this for me.


You are all messing with the global installations and -path files. Just a little error might damage every project you have ever written, and you will spend the rest of the night trying to get a console.log('hi') to work again.

If you have run npm i typescript --save-dev in your project - just try to run:

npx tsc 

And see if it works before messing with global stuff (unless of course you really know what you are doing)


I solved this on my machine by just running sudo npm install in the directory that I was getting the error.


None of above answer solve my problem. The fact is that my project did not have type script installed. But locally I had run npm install -g typescript. So I did not notice that typescript node dependency was not in my package json.

When I pushed it to server side, and run npm install, then npx tsc I get a tsc not found. In facts remote server did not have typescript installed. That was hidden because of my local global typescript install.


  1. Check your npm version

  2. If it's not properly installed, then install it first

  3. run this command npm install typescript -g

  4. now tsc <file_name>.ts

  5. It'll create a corresponding .js file. eg <file_name>.js

  6. now try node <file_name>.js


Examples related to typescript

TS1086: An accessor cannot be declared in ambient context Element implicitly has an 'any' type because expression of type 'string' can't be used to index Angular @ViewChild() error: Expected 2 arguments, but got 1 Typescript: No index signature with a parameter of type 'string' was found on type '{ "A": string; } Understanding esModuleInterop in tsconfig file How can I solve the error 'TS2532: Object is possibly 'undefined'? Typescript: Type 'string | undefined' is not assignable to type 'string' Typescript: Type X is missing the following properties from type Y length, pop, push, concat, and 26 more. [2740] Can't perform a React state update on an unmounted component TypeScript and React - children type?

Examples related to npm

What does 'x packages are looking for funding' mean when running `npm install`? error: This is probably not a problem with npm. There is likely additional logging output above Module not found: Error: Can't resolve 'core-js/es6' Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist` ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.2.0 but 3.2.1 was found instead DeprecationWarning: Buffer() is deprecated due to security and usability issues when I move my script to another server Please run `npm cache clean` What exactly is the 'react-scripts start' command? On npm install: Unhandled rejection Error: EACCES: permission denied Difference between npx and npm?

Examples related to tsc

'tsc command not found' in compiling typescript How do you produce a .d.ts "typings" definition file from an existing JavaScript library?