upgrade angular 4 project to angular 6

upgrade angular 4 to 8
upgrade angular 5 to 6
upgrade angular 2 to 4
upgrade angular 6 to 7
upgrade angular 4 to 5
upgrade angular 4 to 7
angular 8 to angular 9 update
package @angular/cli is not a dependency

I need to upgrade an existing angular 4 project to angular 6

I have followed the steps mentioned in the https://update.angular.io/

npm install -g @angular/cli@6
npm install @angular/cli@6
ng update @angular/cli
ng update @angular/core
ng update 

but these steps are landing in upgrading to angular 7 not angular 6

Screenshot of the result after running the ng update command:

Am I missing any steps, how to upgrade to angular 6 instead of angular 7


First of all you can try giving the full version number that is 6.0.0 where ever you're installing. Secondly, the second install command try adding --save-dev flag to it so that it save it to the dev dependencies directly and then ng update @angular/cli after that ng update then ng update @angular/core. Be sure before the update commands check the ng version using ng --version. Hope this helps!

Upgrading Angular 4, 5 projects to Angular 6, First of all you can try giving the full version number that is 6.0.0 where ever you'​re installing. Secondly, the second install command try adding  Globally upgrade Angular CLI from 1.x to 6; Upgrade Angular CLI version in project; Identify the packages that need an upgrade; Upgrade packages; Solve peer dependency issues; Step 1: Globally upgrade Angular CLI from 1.x to 6. Install the angular-cli 6 globally using below command: npm install -g @angular/cli


In order to upgrade angular-cli package that was installed globally in your system, you need to run following commands

npm uninstall -g angular-cli
npm cache clean or npm cache verify (if npm > 5)
npm install -g @angular/cli@latest

Instead of upgrading global version of angular-cli you can also upgrade the local version for specific project by running following commands:

rm -rf node_modules
npm uninstall --save-dev angular-cli
npm install --save-dev @angular/cli@latest
npm install

hope this will help cheers!

Angular Update Guide, The Angular CLI (now also updated to version 6 to match Angular) I've been updating all my side projects from Angular 4 or 5.2 to 6 just to  The Angular CLI (now also updated to version 6 to match Angular) will make it make much simpler to update projects to future versions of Angular, by using ng update. I’ve been updating all my side projects from Angular 4 or 5.2 to 6 just to see how the process went and it hasn’t been smooth but so far it’s all worked out.


First You need to uninstall both node-modules folder and package-lock.json file. Next you need to perform a basic update using

ng update @angular/core

This upgrades your core package.

ng update @angular/cli --migrate-only --from=YOUR-CURRENT-ANGULAR-VERSION

This upgrades your angular command line tools to support the latest version.

Finally do npm install and run the ng serve command.

Incase you have used rxjs and its throwing errors after upgrading, just npm i rxjs-compat, this will install required dependencies.

Voila,your project is upgraded.

upgrade angular 4 project to angular 6, You don't need to have followed part 1, 2, 3, 4 or 5 of this tutorial for 6 to make sense. You can simply grab a copy of our repo, check out the code  Recently Angular 6 is released. It is released with a lot of new features. Angular 6 is Released with Angular CLI 6 and Material 6. Refer Angular 6 Features, Angular CLI 6 and Angular Material 6 Features for more information. In this post, you will learn How to upgrade or migrate your Angular 5 app to Angular 6.


you can do it by installing nvm, execute below commands in terminal

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | 
bash  

and next

export NVM_DIR="/root/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm uninstall <version>    
nvm install [-s] <version>
nvm alias default <version>

or simply change your angular version in package.json and run

npm install

in terminal

Upgrading to Angular 6!, 15, 18 · Web Dev Zone · Tutorial. Like (4). Comment (6). Save. Tweet Upgrading to Angular 7 takes just a few simple steps: terminal: sudo npm install -g @angular/cli@latest; Upgrade the version locally in your project and  This quick post will tell you how you can upgrade your Angular 6 project within 10 minutes to the new Angular 7 (at the moment of writing beta-7, edit: now major version). Note: this is not an in


Upgrading to Angular v6

The best resource with details on how to upgrade to a new Angular version is https://update.angular.io/. Even if you are upgrading from v2 to v6, it will list all the breaking changes since v2 to v6! It is a great way to know in details what you need to change in your code.

1: Instaling latest Angular CLI

First step is to make sure you have the latest CLI available:

npm install -g @angular/cli

With the release of Angular v6, the Angular CLI is now also versioned as Angular, meaning until Angular v5, we would use Angular CLI 1.x, and now Angular CLI is also on version 6.x. It makes it much easier!

2: ng update

Needless to say, please do create a branch to update your project, as you’ll never know if all dependencies will still work after upgrading to Angular v6.

So first, we will start with @angular/cli. In order for the ng update command to work inside the project, we need first to update the @angular/cli version to 6.x.

npm install --save-dev @angular/cli@latest

Next, run the ng update command for @angular/cli, then @angular/core and then for the other packages required (rxjs, @angular/material):

ng update @angular/cli
ng update @angular/core
ng update @angular/material
ng update rxjs

Some project structure files have changed from v5 to v6. There is no angular-cli.json anymore, it has been replaced by angular.json. The structure of angular.json also has changed to support multiple projects per workspace. When we run ng update @angular/cli all the required files will be updated!

3: Updating other dependencies

I also like to update the other npm depedencies used by the project during an Angular upgrade. The npm package npm-check-updates is really helpful for this task.

npm install -g npm-check-updates

Use the command ncu to check what packages have updates available. And ncu -u to update your package.json.

When changing versions of package of package.json, I personally also like to delete the node_module and run npm i again just to make sure the correct versions are availavle locally (and also update package-lock.json).

4: Updating RxJS

So, next step now is running ng serve to check if everything is ok with the code. Don’t forget to verify https://update.angular.io/ for all beaking changes.

Even though we were able to update RxJS code since Angular v5 (with RxJS v5) to use the pipeble operators, in the projects I did the upgrade to v6, I forgot to change a few places. To help us with this task, we can install rxjs-tslint to help us removing all deprecated RxJS code.

npm install -g rxjs-tslint
rxjs-5-to-6-migrate -p src/tsconfig.app.json

As a quick summary regarding the imports:

import { Subject } from 'rxjs/Subject';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of;'

to:

import { BehaviorSubject, Subject, Observable, of } from 'rxjs';

Or, if you were not using RxJS pipeble operators yet:

import 'rxjs/add/observable/of';    
import 'rxjs/add/operator/catch';   
import 'rxjs/add/operator/do';  
import 'rxjs/add/operator/map'; 
import 'rxjs/add/operator/mergeMap';    
import 'rxjs/add/operator/switchMap';

to

import { of } from 'rxjs';
import { map, switchMap, catchError, mergeMap } from 'rxjs/operators';

The following operators were renamed as well:

do -> tap
catch -> catchError
switch -> switchAll
finally -> finalize

And in our code, we can start using the pipeble operators.

From:

this.http.get('url')
  .do(console.log)
  .map(results => results.data)
  .subscribe(results => {
    console.log('Results', results);
  });

To:

this.http.get('url')
  .pipe(
    tap(console.log), // old 'do' operator
    map(results => results.data)
  )
  .subscribe(results => {
    console.log('Results', results);
  });

After updating your RxJS code, you might still get errors regarding RxJS from third-party dependencies. To solve this, install rxjs-compat and once the dependencies have upgraded their code as well, you can remove this package from your project.

npm install --save rxjs-compat

5: Simplifying Dependency Injection for Core Services

A new feature introduced in Angular v6 is called "tree-shakable providers". This means we no longer need to declare services in a module by using the property providedIn, and this will allow the services to be tree-shakable, meaning if they are not being used, they will not be part of the prod bundle.

import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class MyCoreService { }

I applied this feature in all core services (global scope) of my projects, but I’m still using non tree-shakable providers with services that do not have global scope.

This allowed to clean up the providers section from CoreModule.

6: Updating Angular Material (optional)

If you are using Angular Material in your project, don’t forget to run ng update @angular/material to update the material dependencies.

A breaking change from v5 to v6 is how we import the Material modules in our project:

From:

import {
  MdToolbarModule,
  MdIconModule,
  MdButtonModule,
  MdMenuModule,
  MdCardModule
} from '@angular/material';

To:

import { MatToolbarModule } from '@angular/material/toolbar';
import { MatIconModule } from '@angular/material/icon';
import { MatButtonModule } from '@angular/material/button';
import { MatMenuModule } from '@angular/material/menu';
import { MatCardModule } from '@angular/material/card';

Now each module has its own package. This is also one of the reasons I like to create a separate module for thrid party imports as already explained in this article. It makes much easier to fix imports!

Some other things… I do have some projects that were created since Angular v2, and after every major version update, I usually just updated package.json and fixed the breaking changes in the code and that was ok.

Since there were some project structure changes in Angular CLI v6, I also decided to migrate a project by creating a brand new project with CLI 6 and copying the src folder from the old project to the new project. Below are some of the most impacted changes.

The major difference that had some impact on the code is the baseUrl: './' from tsconfig.json. With projects created with CLI 1.x (for Angular v4 and v5), this configuration is not there by default (but inside src/tsconfig.ap.json). Moving baseUrl to the root tsconfig.json had an impact on custom paths declared in tsconfig.json and also on the path for lazy loading modules.

Before - custom path in tsconfig.json:

paths: {
  "@env/*": ["environments/*"]
}

After (single project created with CLI v6):

paths: {
  "@env/*": ["src/environments/*"]
}

And the lazy loading modules need to be declared using the relative path:

Before:

{ path: 'home', loadChildren: 'app/home/home.module#HomeModule' }

After:

{ path: 'home', loadChildren: './home/home.module#HomeModule' }

If you have nested modules, you also need to update them to use relative paths:

Before (module1-routing.module.ts):

{ path: 'foo', loadChildren: 'app/module1/module2/module2.module#Module2Module' }

After (module1-routing.module.ts):

{ path: 'foo', loadChildren: './module2/module2.module#Module2Module' }

There were a few changes in the CLI v6 commands as well. As the majority of my professional applications use Java in the backend, the output folder (dist) from ng build is configured to a different path. Until CLI 1.x, there was a flag (output-path -op) that could be used in the ng build command (ng build -op ../other/path). With CLI v6, if you need to use a different output path, you need to update angular.json and remove the -op flag from ng build:

"architect": {
  "build": {
    "builder": "@angular-devkit/build-angular:browser",
    "options": {
      "outputPath": "../other/path",
      ...
    }
  }
} 

How to Update Angular Projects to the Latest Version, Updating Angular CLI to v9 and upgrading your project to Angular 9 7.1.4 @​schematics/update 0.11.4 rxjs 6.3.3 typescript 3.1.6 webpack  Updating Angular CLI to v9 and upgrading your project to Angular 9 from v8/7 is now easier than ever before, thanks to all the work that has been done in version 9 and the ng update command which allows you to update specific versions and dependencies.


Upgrade to Angular 7 in 5 Simple Steps, 4. I wanted to see any big differences in files like angular-cli.json between my project and projects created with the new version of the CLI so I  I have a large project I’m working on that’s still in development so I decided to take the plunge and try out some of the new features to upgrade from Angular 5 to Angular 6. Here are the specific steps I went though along with some commentary along the way. Additional upgrade documentation can be found here.


Upgrade Angular 8/7 to Angular 9 With Ng Update & Angular CLI v9 , How to upgrade Angular 6, 7 or any lower version to Angular 8, 4.) Create new Angular 8 Project by running following command on Node.js  Upgrade the existing application’s AngularJS version to 1.6 from 1.3 and get it running in a Angular CLI environment. Set up the routing handling between Angular and AngularJS


Upgrading an Application to Angular 6: Step By Step – Code with , First, it makes sure that Angular and AngularJS run in the correct zones, and then it sets up an extra module that allows AngularJS to be visible in Angular and Angular to be visible in AngularJS. Lastly, it adapts the testability APIs, so that Protractor will work with hybrid apps, which is super important.