如何将Angular CLI升级到最新版本 [英] How to upgrade Angular CLI to the latest version

查看:95
本文介绍了如何将Angular CLI升级到最新版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ng --version我得到了:

@ angular/cli:1.0.0

@angular/cli: 1.0.0

这不是可用的最新版本.

which is not the latest release available.

由于我的系统上全局安装了Angular CLI,因此为了对其进行升级,我尝试:

Since I have Angular CLI globally installed on my system, in order to upgrade it I tried:

npm update angular-cli -g

但是它不起作用,因为它保持1.0.0版本.

But it does not work, because it stays to 1.0.0 version.

推荐答案

阅读了GitHub存储库上报告的一些问题之后,我找到了解决方案.

After reading some issues reported on the GitHub repository, I found the solution.

为了更新系统中全局安装的angular-cli软件包,您需要运行:

In order to update the angular-cli package installed globally in your system, you need to run:

npm uninstall -g @angular-cli
npm install -g @angular/cli@latest

根据您的系统,您可能需要在上述命令前面加上sudo.

Depending on your system, you may need to prefix the above commands with sudo.

此外,您很可能还希望更新本地项目版本,因为在项目目录中将其选择的优先级高于全局目录的优先级:

Also, most likely you want to also update your local project version, because inside your project directory it will be selected with higher priority than the global one:

rm -rf node_modules
npm uninstall --save-dev @angular-cli
npm install --save-dev @angular/cli@latest
npm install

感谢 grizzm0 GitHub .

更新CLI后,您可能也想更新Angular版本.

After updating your CLI, you probably want to update your Angular version too.

注意:如果要从较早版本更新到Angular CLI 6+,则可能需要阅读

Note: if you are updating to Angular CLI 6+ from an older version, you might need to read this.

编辑:此外,如果您仍使用cli的1.x版本,则需要将angular-cli.json转换为angular.json,可以使用以下命令进行操作:

Edit: In addition, if you were still on a 1.x version of the cli, you need to convert your angular-cli.json to angular.json, which you can do with the following command:

ng update @angular/cli --from=1.7.4 --migrate-only

(有关更多详细信息,请参见)

(check this for more details).

这篇关于如何将Angular CLI升级到最新版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆