How to update TypeScript to latest version with npm?

TypescriptNpmNpm Install

Typescript Problem Overview


Currently I have TypeScript 1.0.3.0 version installed on my machine.
I want to update it to latest one i.e. 2.0.

How to do this with npm?

Typescript Solutions


Solution 1 - Typescript

Try npm install -g typescript@latest. You can also use npm update instead of install, without the latest modifier.

Solution 2 - Typescript

Open command prompt (cmd.exe/git bash)

Recommended:

npm install -g typescript@latest

or

yarn global add typescript@latest  // if you use yarn package manager

This will install the latest typescript version if not already installed, otherwise it will update the current installation to the latest version.

And then verify which version is installed:

tsc -v

enter image description here


If you have typescript already installed you could also use the following command to update to latest version, but as commentators have reported and I confirm it that the following command does not update to latest (as of now [ Feb 10 '17])!

npm update -g typescript@latest

Solution 3 - Typescript

If you are on Windows and have Visual Studio installed you might have something in your PATH that is pointing to an old version of TypeScript. I found that removing the folder "C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0" from my PATH (or deleting/renaming this folder) will allow the more recent npm globally installed TypeScript version of tsc to work.

Solution 4 - Typescript

You should be able to do this by simply typing npm install -g [email protected]. If this does not work, I am beginning to wonder what version of node and npm you are on. Try node -v and npm -v to find these out. You should be on node >4.5 and npm >3

Solution 5 - Typescript

For npm: you can run:

npm update -g typescript

By default, it will install latest version.

For yarn, you can run:

yarn upgrade typescript

Or you can remove the orginal version, run yarn global remove typescript, and then execute yarn global add typescript, by default it will also install the latest version of typescript.

more details, you can read yarn docs.

Solution 6 - Typescript

My solution to this error was to update the typescript version with this command:

npm install -g typescript@latest as I was using Windows. However on Mac this can also be doable by sudo npm install -g typescript@latest

Solution 7 - Typescript

Just use the command # npm update -g typescript
For update all global installed module, Use this command# npm update -g

Solution 8 - Typescript

Use the command where in prompt to find the current executable in path

C:\> where tsc
C:\Users\user\AppData\Roaming\npm\tsc
C:\Users\user\AppData\Roaming\npm\tsc.cmd

Solution 9 - Typescript

If you are using Windows with very old NodeJS, then uninstall previous NodeJs and NVM (Node Version Manager) in Control Panel (Win7) or Settings/Apps (Win10) if exists. Make sure that they are removed from the PATH.

Reinstall NodeJS: https://nodejs.org/en/download It will install NPM as well.

Install TypeScript globally:

npm install -g typescript

Verify installation:

tsc -v

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionblueMoonView Question on Stackoverflow
Solution 1 - TypescripteavidanView Answer on Stackoverflow
Solution 2 - TypescriptLegendsView Answer on Stackoverflow
Solution 3 - TypescriptVeenerView Answer on Stackoverflow
Solution 4 - TypescriptAndrew ReidView Answer on Stackoverflow
Solution 5 - TypescriptLittle RoysView Answer on Stackoverflow
Solution 6 - TypescriptgildniyView Answer on Stackoverflow
Solution 7 - TypescriptPascal TovoheryView Answer on Stackoverflow
Solution 8 - TypescriptimpactroView Answer on Stackoverflow
Solution 9 - TypescriptDonato SzilagyiView Answer on Stackoverflow