如何获得 Angular 版本? [英] How to get the Angular version?
问题描述
我使用以下命令通过 npm 安装了 @angular/cli
包:
I installed the @angular/cli
package via npm using:
npm install -g @angular/cli
@angular/cli
1.4.2 版本已经安装成功.那不是 Angular 版本,而是 CLI 版本.
The version 1.4.2 of @angular/cli
has been successfully installed. That is not the Angular version, but the CLI version.
运行 ng new myapp
后,如何检查创建的应用程序使用的是哪个 Angular 版本?2.x、4.x?
After running ng new myapp
how can I check which Angular version the created app is using? 2.x, 4.x?
推荐答案
ng version
您全局安装了 angular cli(命令中的 -g).这意味着您可以在命令提示符中键入 ng version
.当您的命令提示符不是在 npm 控制的目录中时,这样做可能更精确(您应该在您输入的目录中输入ng new myapp
).
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
).
给那些从 Google 来到这里的人的说明: ng version
会让你知道当前目录引用了哪个(粗略)版本的 Angular.例如此目录似乎安装了 angular 4.x (~4.3.0).
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
如果您不在一个包含 packages.config 的目录中,那么您将获得 Angular: ...
.
If you are not within a directory which has a packages.config, then you will get Angular: ...
.
这篇关于如何获得 Angular 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!