How to update Angular 4,5, 6 to Angular 7?

by garnet.barrows , in category: Technology , 3 years ago

How to update Angular 4,5, 6 to Angular 7?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by bria_metz , 3 years ago
  • First of all, you need to update the Angular version globally by inserting the latest version via the terminal: sudo npm install -g @angular/cli@latest.
  • The next step is to upgrade the version locally in your project and need to assure the altering for the new version are displayed in the package.json file ng update @angular/cli
  • When it is done, upgrade all your dependencies and dev dependencies in package.json
  • To build Angular applications, Angular-devkit was introduced in Angular 6 that needs the dependency on the CLI projects.
  • With all of this, you'll also require to upgrade the version for Typescriptnpm install typescript@2.9.2 --save-dev
  • Then, you need to relocate the configuration of angular-cli.json to angular.json ng update @angular/cli and ng update @angular/core.
  • Use this command: ng update @angular/material in case of Angular material is used.
  • The next step is the removal of deprecated RxJS 6 features npm install -g rxjs-tslint rxjs-5-to-6-migrate -p src/tsconfig.app.json
  • When it is done, uninstall rxjs-compat as it is not required for Angular npm uninstall --save rxjs-compat
  • Also change import { Observable } from 'rxjs/Observable'; to import { Observable } from 'rxjs';
  • Finally, you are able to start your Angular 7 application by using ng serve