如何检查Angular版本? [英] How to check the Angular version?

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

问题描述

我使用以下命令通过npm安装了@angular/cli软件包:

npm install -g @angular/cli

已成功安装@ angular/cli的1.4.2版本.但这不是Angular版本,而是CLI版本.

运行ng new myapp后,如何检查创建的应用程序是哪个Angular版本? 2.x,4.x?

解决方案

ng version

您已全局安装了角度cli(在命令中为-g).这意味着您可以在命令提示符下键入ng version.当命令提示符不是npm受控目录中的 not 时,执行此操作可能会更精确(您在键入ng new myapp的目录中键入此命令).

给那些从Google到这里的人的注释: ng version将使您知道当前目录引用了哪个(粗略)版本的Angular. 例如该目录似乎安装了angular 4.x(〜4.3.0).

@angular/cli: 1.2.1
node: 8.11.1
os: win32 x64
@angular/common: 4.3.0
@angular/compiler: 4.3.0
@angular/core: 4.3.0
@angular/forms: 4.3.0
@angular/http: 4.3.0
@angular/platform-browser: 4.3.0
@angular/platform-browser-dynamic: 4.3.0
@angular/router: 4.3.0
@angular/cli: 1.2.1
@angular/compiler-cli: 4.3.0

如果您不在具有packages.config的目录中,则将获得Angular: ....

I installed @angular/cli package via npm, using this command:

npm install -g @angular/cli

The version 1.4.2 of @angular/cli has been successfully installed. But that is not the Angular version, but the CLI version.

After running ng new myapp how can I check which Angular version the created app is? 2.x, 4.x?

解决方案

ng version

You installed angular cli globally (-g in the command). This means that you can type ng version into your command prompt. It may be more precise to do this when your command prompt is not within a npm controlled directory (you should type this in within directory you typed ng new myapp).

A note to those who got here from Google: ng version will let you know which (coarse) version of Angular is referenced by the current directory. e.g. This directory appears to have angular 4.x (~4.3.0) installed.

@angular/cli: 1.2.1
node: 8.11.1
os: win32 x64
@angular/common: 4.3.0
@angular/compiler: 4.3.0
@angular/core: 4.3.0
@angular/forms: 4.3.0
@angular/http: 4.3.0
@angular/platform-browser: 4.3.0
@angular/platform-browser-dynamic: 4.3.0
@angular/router: 4.3.0
@angular/cli: 1.2.1
@angular/compiler-cli: 4.3.0

If you are not within a directory which has a packages.config, then you will get Angular: ....

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

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