1

When using npx tsc --init without typescript installed, NPM seems to go through the motions to download tsc, and has some commands, but not all (it doesn't have --init), and I realize its because its using a really old version of tsc. Thats annoying, it should use the latest one :)

To reproduce this yourself, make sure you don't have typescript installed globally and also are not in a NPM project (with package.json). Then type npx tsc --version: you will get

npx: installed 1 in 0.868s
message TS6029: Version 1.5.3

Obviously the workaround is to install typescript first, but then there is no point of npx, is there? Only then do I get the latest version:

Version 4.1.3
Ben Butterworth
  • 22,056
  • 10
  • 114
  • 167

1 Answers1

2

As Estus Flask said in his answer here, when you use tsc without typescript installed, you are using the deprecated tsc package, which I personally wasn't able to find using https://www.npmjs.com/search?q=tsc probably because it has fallen way down in the search ranking.

His answer has more detail and tips to make npx still work without installing typescript: npx -p typescript tsc (-p means "Package to be installed.")


After typing the question, it looks like a similar question has been asked before. But this question has got nothing to do with virtual machines (the original question): "npx tsc --version" reports different TypeScript version inside virtual machine

Ben Butterworth
  • 22,056
  • 10
  • 114
  • 167