1

I was having a problem with tsc command. Then I saw here 'tsc command not found' in compiling typescript that I could use npx tsc app.ts and it worked. Could anyone explain to me why just tsc app.ts didn't work ? The error message was 'tsc command not found' and my TypeScript version is 3.8.3

Thanks !!

2 Answers2

1

Solve this by installing TypeScript globally:

[sudo] npm i -g typescript

…or keep the same behaviour as explained by @strdr4605 since it works.

Federico Moretti
  • 527
  • 1
  • 11
  • 22
  • 1
    I had installed TypeScript globally with ``npm -g typescript`` but I just made it again using the command that you suggested ``npm i -g typescript`` and it worked. Thanks!! – Amanda Cossu Mar 23 '20 at 09:28
0

From npx docs:

Executes <command> either from a local node_modules/.bin, or from a central cache, installing any packages needed in order for <command> to run.

So if typescript is not installed globally or locally the npx first will download it and then run the tsc binary.

strdr4605
  • 3,796
  • 2
  • 16
  • 26