Omar Bahir
Omar Bahir

Reputation: 1257

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. ?

Upvotes: 17

Views: 73870

Answers (6)

mbspark
mbspark

Reputation: 611

On my mac, I simply ran sudo rm -rf /usr/local/bin/tsc and then installed the version I wanted: npm install -g [email protected] and it worked after failing to use npm uninstall.

Upvotes: 2

Issa
Issa

Reputation: 112

You probably are missing

sudo

Do something like this below:

npm uninstall -g typescript

Upvotes: 0

the Hutt
the Hutt

Reputation: 18418

On Linux Fedora 36 I had to do:

sudo dnf remove nodejs-typescript

Command output:

Dependencies resolved.ejs-typescript
=============================================================================
 Package              Architecture   Version           Repository  Size
=============================================================================
Removing:
 nodejs-typescript    noarch         4.1.3-4.fc36      @fedora     53 M

Transaction Summary
=============================================================================
Remove  1 Package


Then to get the latest version I did:

sudo npm install -g typescript

Upvotes: 0

Mateus Gonçalves
Mateus Gonçalves

Reputation: 706

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 Ubuntu Linux

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.

Upvotes: 8

FOR LINUX:

if npm uninstall doens't work - try this command with sudo. This is the way out for me

sudo npm uninstall -g typescript

sudo npm uninstall -g tsc

Upvotes: 0

Sohaib Furqan
Sohaib Furqan

Reputation: 331

Please type:

npm uninstall -g typescript

instead of

npm uninstall -g tsc

That should solve your problem! :)

Upvotes: 18

Related Questions