Angular-使用ng update命令升级到Angular7.1.4
Angular CLI 是 Angular 的一个命令行工具,可以便捷的执行创建项目、创建文件、测试、打包和发布等任务。
Angular 2.x及以上统称Angular
. Angular 1.x 则称为 AngularJS
.
Angular 2 发布于 2016年09月14日。
Angular 4 发布于 2017年03月23日。
Angular 5 发布于 2017年11月01日。
Angular 6 发布于 2018年05月03日。
Angular 7 发布于 2018年10月18日。
使用npm
命令安装@angular/cli
:
$ npm install -g @angular/cli
参数-g
表示全局安装。
代码实例:
$ npm install -g @angular/cli
/usr/local/bin/ng -> /usr/local/lib/node_modules/@angular/cli/bin/ng
+ @angular/cli@7.1.4
updated 9 packages in 16.798s
使用 ng update
命令可以查看更新:
如果有packages
更新,会提示出来,并给出更新命令:
$ ng update
We analyzed your package.json, there are some packages to update:
Name Version Command to update
-----------------------------------------------------------
@angular/cli 7.1.3 -> 7.1.4 ng update @angular/cli
@angular/core 7.1.3 -> 7.1.4 ng update @angular/core
There might be additional packages that are outdated.
Run "ng update --all" to try to update all at the same time.
可以看到,当前项目下有2个包可以更新。
(1) 使用 ng update
更新 @angular/cli
包:
$ng update @angular/cli
Updating package.json with dependency @angular/cli @ "7.1.4" (was "7.1.3")...
UPDATE package.json (1528 bytes)
updated 9 packages in 20.362s
再次查看,还有@angular/core
需要更新:
$ ng update
We analyzed your package.json, there are some packages to update:
Name Version Command to update
--------------------------------------------------------------
@angular/core 7.1.3 -> 7.1.4 ng update @angular/core
There might be additional packages that are outdated.
Run "ng update --all" to try to update all at the same time.
(2) 使用 ng update
更新 @angular/core
包:
$ng update @angular/core
Updating package.json with dependency @angular/compiler-cli @ "7.1.4" (was "7.1.3")...
Updating package.json with dependency @angular/language-service @ "7.1.4" (was "7.1.3")...
Updating package.json with dependency @angular/core @ "7.1.4" (was "7.1.3")...
Updating package.json with dependency @angular/common @ "7.1.4" (was "7.1.3")...
Updating package.json with dependency @angular/platform-browser @ "7.1.4" (was "7.1.3")...
Updating package.json with dependency @angular/compiler @ "7.1.4" (was "7.1.3")...
Updating package.json with dependency @angular/animations @ "7.1.4" (was "7.1.3")...
Updating package.json with dependency @angular/router @ "7.1.4" (was "7.1.3")...
Updating package.json with dependency @angular/forms @ "7.1.4" (was "7.1.3")...
Updating package.json with dependency @angular/platform-browser-dynamic @ "7.1.4" (was "7.1.3")...
Updating package.json with dependency @angular/http @ "7.1.4" (was "7.1.3")...
UPDATE package.json (1528 bytes)
updated 11 packages in 49.411s
再次使用 ng update
检测,已经没有新的更新了。
$ ng update
We analyzed your package.json and everything seems to be in order. Good work!
(3) 更新完成后,使用 ng version
查看各个包的版本:
$ ng version
Angular CLI: 7.1.4
Node: 10.11.0
OS: darwin x64
Angular: 7.1.4
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.10.6
@angular-devkit/build-angular 0.10.6
@angular-devkit/build-optimizer 0.10.6
@angular-devkit/build-webpack 0.10.6
@angular-devkit/core 7.0.6
@angular-devkit/schematics 7.1.4
@ngtools/webpack 7.0.6
@schematics/angular 7.1.4
@schematics/update 0.11.4
rxjs 6.3.3
typescript 3.1.6
webpack 4.19.1
https://github.com/angular/angular-cli/wiki
[END]