Version 7 of Angular has been released 官方角度博客链接. Visit official angular update guide https://update.angular.io for detailed information. These steps will work for basic angular 6 apps using Angular Material.
ng update @angular/cli
ng update @angular/core
ng update @angular/material
从 Angular v5升级到 Angular v6
版本6 的 Angular 已经发布了 官方角度博客链接。
I have mentioned general upgrade steps below, but before and after the update you need to make changes in your code to make it workable in v6, for that detailed information visit official website https://update.angular.io .
npm install -g @angular/cli
npm install @angular/cli
ng update @angular/cli
Update all of your Angular framework packages to v6,and the correct version
of RxJS and TypeScript by running the following:
ng update @angular/core
Update Angular Material to the latest version by running the following:
ng update @angular/material
RxJS v6 has major changes from v5, v6 brings backwards compatibility package rxjs-compat that will keep your applications working, but you should refactor TypeScript code so that it doesn't depend on rxjs-compat. To refactor TypeScript code run following:
Done run ng serve to check it.
If you get errors in build refer https://update.angular.io for detailed info.
Upgrade from Angular v5 to Angular 6.0.0-rc.5
Upgrade rxjs to 6.0.0-beta.0, please see this RxJS Upgrade Guide for more info. RxJS v6 has breaking change hence first make your code compatible to latest RxJS version.
Update NodeJS version to 8.9+ (this is required by angular cli 6 version)
Update Angular cli global package to next version.
npm uninstall -g @angular/cli
npm cache verify
如果 npm 版本 < 5,则使用 npm cache clean
npm install -g @angular/cli@next
Change angular packages versions in package.json file to ^6.0.0-rc.5
Next update Angular cli local package to next version and install above mentioned packages.
rm -rf node_modules dist # use rmdir /S/Q node_modules dist in Windows
Command Prompt; use rm -r -fo node_modules,dist in Windows PowerShell
npm install --save-dev @angular/cli@next
npm install
The Angular CLI configuration format has been changed from angular cli 6.0.0-rc.2 version, and your existing configuration can be updated automatically by running the following command. It will remove old config file .angular-cli.json and will write new angular.json file.
ng update @angular/cli --migrate-only --from=1.7.4
Note :- If you get following error "The Angular Compiler requires TypeScript >=2.7.2 and <2.8.0 but 2.8.3 was found instead". run following command :