Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to uninstall typescript globally through npm

I've installed typescript 2.4.1 on my system globally (tsc -v gives me version 2.4.1). I want to uninstall it as I want to go to version 2.3.4 for some of my e2e tests to work. But right now I'm unable to uninstall it. I tried to uninstall through npm

npm uninstall -g tsc

but after running the command when I run

tsc -v 

it again shows me

version  2.4.1.

I've search this problem and found some solutions

uninstalling typescript without node and npm installing old versions of (typescript compiler) package but I've tried all i.e. try to find if in installed programs but could not find it. Then going into

C:\Program Files (x86)\Microsoft SDKs\TypeScript

to delete the folder manually but there was version 2.3, not 2.4.1 which its showing in command prompt.

Any help how can I get rid of typescript 2.4.1. ?

like image 576
Omar Bahir Avatar asked Sep 29 '17 05:09

Omar Bahir


2 Answers

Please type:

npm uninstall -g typescript

instead of

npm uninstall -g tsc

That should solve your problem! :)

like image 101
Sohaib Furqan Avatar answered Oct 02 '22 18:10

Sohaib Furqan


FOR WINDOWS You might have an old TypeScript installation on your computer because of a Microsoft SDK:

cmd>tsc --version
Version 1.0.3.0

If you check the PATH environment variable, you may find an entry like this:

C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\

In my case, the uninstallation of "TypeScript Tools for Microsoft Visual Studio 2015" did not remove tsc.exe etc. from this path, probably because it was installed as part of the Windows 10 SDK or something else.

You can remove the entry from the PATH environment variable or at least move it below the entry for Node.js (probably C:\Program Files\nodejs) or nvm (like C:\Users\<username>\AppData\Roaming\nvm) in case you use Node Version Manager. This will prevent that calls to tsc run the ancient TypeScript compiler:

cmd>tsc --version
Version 3.1.3

Don't forget to restart your command line after changes to environment variables for them to take effect!

If you are unsure what binary the tsc command will actually run then use the where command to find out:

cmd>where tsc
C:\Program Files\nodejs\tsc
C:\Program Files\nodejs\tsc.cmd
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\tsc.exe
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\tsc.js

The priority is top to bottom. The first entry in my case is a (Linux) shell script and usually not executable on Windows. The second entry is a Windows Batch script and this is the one that will be executed. It basically invokes Node.js (simplified):

node.exe node_modules\typescript\bin\tsc

OR

You can now uninstall "TypeScript Tools for Microsoft Visual Studio 2015" from the Control Panel in Programs and Features. It was automatically installed with Visual Studio 2015 in my case.

FOR UBUNUT

Uninstall node-typescript To uninstall only node-typescript from Ubuntu 16.04 (Xenial Xerus) run in terminal:

sudo apt-get remove node-typescript

Uninstall node-typescript and dependent packages To uninstall the node-typescript package and any other dependent packages that are no longer needed by Ubuntu Xenial.

sudo apt-get remove --auto-remove node-typescript

Expunge node-typescript If you also want to clear the node-typescript settings and / or data from Ubuntu Xenial then use this command:

sudo apt-get purge node-typescript

To clear the node-typescript settings and / or data files and their Ubuntu Xenial dependent packages, run:

sudo apt-get purge --auto-remove node-typescript

More information about apt-get remove

Advanced Package Tool, or APT, is a free software user interface that works with core libraries to handle the installation and removal of software on Debian, Ubuntu and other Linux distributions. APT simplifies the process of managing software on Unix-like computer systems by automating the retrieval, configuration and installation of software packages, either from precompiled files or by compiling source code.

apt-get is the command-line tool for handling packages, and may be considered the back end user to other tools using the APT library.

apt-get remove is identical to install except that packages are removed instead of installed. Note that removing a package leaves its configuration files on the system. If a plus sign is appended to the package name (with no intervening space), the identified package will be installed instead of removed.

like image 30
Mateus Gonçalves Avatar answered Oct 02 '22 19:10

Mateus Gonçalves