如何使用npm将TypeScript更新到最新版本?

时间:2022-07-12 07:27:21

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.

目前,我的机器上安装了TypeScript 1.0.3.0版本。我想将它更新为最新版本,即2.0。

How to do this with npm?

用npm怎么做?

5 个解决方案

#1


171  

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

试试npm install -g typescript @ latest。您也可以使用npm update而不是install,而不使用最新的修饰符。

#2


39  

On Windows I do (open command prompt - cmd)

在Windows上我做(打开命令提示符 - cmd)

npm update -g typescript@latest

or

要么

npm install -g typescript@latest

You can use both commands for updating, whereas the latter one will also install typescript if it has not been installed already

您可以使用这两个命令进行更新,而后者也可以安装typescript(如果尚未安装)

and then test the version using

然后使用测试版本

tsc -v

如何使用npm将TypeScript更新到最新版本?

#3


22  

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.

如果您使用的是Windows并安装了Visual Studio,则可能在PATH中有一些指向旧版本TypeScript的内容。我发现从我的PATH中删除文件夹“C:\ Program Files(x86)\ Microsoft SDKs \ TypeScript \ 1.0 \”(或删除/重命名此文件夹)将允许更新的npm全局安装的TypeScript版本的tsc工作。

#4


10  

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

您只需输入npm install -g typescript@2.0就可以完成此操作。如果这不起作用,我开始想知道你所使用的节点和npm的版本。尝试使用node -v和npm -v来查找这些内容。您应该在节点> 4.5和npm> 3

#5


0  

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

只需使用命令#npm update -g typescript要更新所有全局安装模块,请使用此命令#npm update -g

#1


171  

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

试试npm install -g typescript @ latest。您也可以使用npm update而不是install,而不使用最新的修饰符。

#2


39  

On Windows I do (open command prompt - cmd)

在Windows上我做(打开命令提示符 - cmd)

npm update -g typescript@latest

or

要么

npm install -g typescript@latest

You can use both commands for updating, whereas the latter one will also install typescript if it has not been installed already

您可以使用这两个命令进行更新,而后者也可以安装typescript(如果尚未安装)

and then test the version using

然后使用测试版本

tsc -v

如何使用npm将TypeScript更新到最新版本?

#3


22  

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.

如果您使用的是Windows并安装了Visual Studio,则可能在PATH中有一些指向旧版本TypeScript的内容。我发现从我的PATH中删除文件夹“C:\ Program Files(x86)\ Microsoft SDKs \ TypeScript \ 1.0 \”(或删除/重命名此文件夹)将允许更新的npm全局安装的TypeScript版本的tsc工作。

#4


10  

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

您只需输入npm install -g typescript@2.0就可以完成此操作。如果这不起作用,我开始想知道你所使用的节点和npm的版本。尝试使用node -v和npm -v来查找这些内容。您应该在节点> 4.5和npm> 3

#5


0  

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

只需使用命令#npm update -g typescript要更新所有全局安装模块,请使用此命令#npm update -g