'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
Solution 1:
A few tips in order
- restart the terminal
- restart the machine
- reinstall nodejs + then run
npm install typescript -g
If it still doesn't work run npm config get prefix
to see where npm install -g is putting files (append bin
to the output) and make sure that they are in the path (the node js setup does this. Maybe you forgot to tick that option).
Solution 2:
I had to do this:
npx tsc app.ts
Solution 3:
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)