Issue
So I was missing typescript on my server and tryed to run tsc and I got the message "don't recognize tsc command, did you mean to install it using apt install tsc?" or something like that. Not really thinking about it, I ran the command. Usually I'd install it using npm i -g typescript. It did install typescript but at the wrong version (2.7.something and i need 4.0+) and runing tsc -v returns the version, but apt-get update doesn't update it, it doesn't turn up on the list when I run dpkg --list, apt-get remove/apt remove tsc/typescript does nothing (can't find package tsc/typescript) but the tsc command does work and attempts to compile my files but throws a bad type error because it's an old version. npm uninstall/remove -g tsc/typescript also does nothing.
How do I remove this tsc and install typescript normally through npm?
EDIT: I should also note, it's not installed locally in some folder. I get the same behaviour anywhere on the server.
Here's a screenshot of some of the commands I tried and the result I got:
Solution
(Note: Additional information can be found in the chat discussion)
TL;DR: It's probably because you've installed the node-typescript
package via apt-get
at some point, which only provides v2.7.2
as the latest version of TypeScript for your current Ubuntu version (which you've specified is 18.04 LTS, or Bionic Beaver).
This means that you either have to:
- Switch to a newer version of Ubuntu (e.g. the latest stable, 20.04 - Focal Fossa) which offers
v3.8.3
as the current version, or - Uninstall the
node-typescript
package (withsudo apt-get remove node-typescript
) and instead install TypeScript via NPM. This means that TypeScript updates are now decoupled from Ubuntu releases.
Answered By - Edric Answer Checked By - Mary Flores (WPSolving Volunteer)