ng更新到特定的Angular版本

Jaa*_*aap 11 angular

我想将Angular从5.0版更新到6.1版。https://update.angular.io/上的说明建议使用ng update @angular/core进行更新。但是,这直接更新到版本7,而不是版本6。

它的文档ng update建议使用--to将更新为特定版本。但是,这似乎不起作用。使用的确切命令是:ng update @angular/core --to 6.1.0但这将更新为7.0.0

编辑:

我试过使用,--from=5.0.0 --to=6.1.9但是没有用。我注意到我们正在使用angular-cliversion 1.6.4--next根据文档,此版本支持应使用的版本。(Default: false) Install the next version, instead of the latest.但这更改了所有软件包的package.json使用版本7.0.0@angular/*

小智 20

在此处添加此内容,因为这会出现在搜索结果中,并且此处提供的答案对我不起作用。

对我有用的是使用ng update @angular/core@7.0.0。这可能应该在《 Angular更新指南》(https://update.angular.io/)中加以说明,但事实并非如此。由于在一次跨多个主要版本升级时,该页面会发出通知,但使用建议的命令ng update @angular/core升级到最新版本(可能跨多个主要版本),因此可能应对此进行更改。

  • 您还可以执行“ng update @angular/core@7”,这将为您提供版本 7 的最后一个次要版本 (2认同)

atc*_*way 5

您可以使用@符号在所需的每个软件包上指定版本。当前推荐的将Angular升级到较新版本(或您指定的版本)的方法是使用以下命令:

ng update @angular/cli @angular/core
Run Code Online (Sandbox Code Playgroud)

在这种情况下,假设我要升级到8.1.1而不是最新版本,8.2.0我将使用以下内容:

ng update @angular/cli@8.1.1 @angular/core@8.1.1
Run Code Online (Sandbox Code Playgroud)

这是你做任何NPM安装时所解释的指定一个特定版本以同样的方式在这里