How to update TypeScript to latest version with np

2019-01-21 18:06发布

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?

5条回答
仙女界的扛把子
2楼-- · 2019-01-21 18:31

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

查看更多
ら.Afraid
3楼-- · 2019-01-21 18:31

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

查看更多
地球回转人心会变
4楼-- · 2019-01-21 18:40

On Windows open command prompt (cmd)

Recommended:

npm install -g typescript@latest

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)!

npm update -g typescript@latest
查看更多
你好瞎i
5楼-- · 2019-01-21 18:46

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.

查看更多
相关推荐>>
6楼-- · 2019-01-21 18:54

You should be able to do this by simply typing npm install -g typescript@2.0. 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

查看更多
登录 后发表回答