I have recently installed Angular 6 and would like to go back to using Angular 5.2 How can I change my Angular version from whatever version I have to whichever one I choose?
- 
                    5Possible duplicate of [Angular downgrade from version 5 to 4](https://stackoverflow.com/questions/47186038/angular-downgrade-from-version-5-to-4) – Narm May 18 '18 at 16:14
3 Answers
I will try to give a general answer for future similar issues.
The version of angular used in a project is determined by the version of angular cli installed. Any specific version of angular cli can be installed with the following command:
npm install --global @angular/cli@x.x.x.
example:
npm install --global @angular/cli@1.6.6
even if you have another version of angular cli (either newer or older) installed. That should not cause issues. However to be sure you can use:
npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli@1.6.1
 
    
    - 19
- 7
 
    
    - 513
- 1
- 4
- 19
First you need to uninstall, install the cli
npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli@1.6.1
After this, delete node_modules directory
Then change your package versions in package.json to have versions like the following
{
  ...
  },
  ...
  "dependencies": {
    "@angular/animations": "5.2.2",
    "@angular/cdk": "^5.2.2",
    "@angular/common": "5.2.2",
    "@angular/compiler": "5.2.2",
    "@angular/core": "5.2.2",
    "@angular/forms": "5.2.2",
    "@angular/http": "5.2.2",
    "@angular/material": "^5.2.2",
    "@angular/platform-browser": "5.2.2",
    "@angular/platform-browser-dynamic": "5.2.2",
    "@angular/router": "5.2.2",
    "@ngrx/core": "^1.2.0",
    "@ngrx/store": "^4.0.3",
    "core-js": "^2.5.1",
    "hammerjs": "^2.0.8",
    "rxjs": "^5.5.2",
    "typescript": "^2.4.2",
    "web-animations-js": "^2.3.1",
    "zone.js": "^0.8.18"
  },
  "devDependencies": {
    "@angular/cli": "1.6.1",
    "@angular/compiler-cli": "5.2.2",
    "@angular/language-service": "5.2.2",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    ...
  }
}
and install packages
npm install
 
    
    - 9,871
- 5
- 42
- 52
Check the version currently installed by:
# ng version
Angular CLI: 12.1.0
Node: 12.18.4
Package Manager: npm 6.14.6
OS: linux x64
Angular: 12.2.10
... animations, common, compiler, compiler-cli, core, forms
... google-maps, platform-browser, platform-browser-dynamic
... router
Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1201.0
@angular-devkit/build-angular   12.1.0
@angular-devkit/core            12.1.0
@angular-devkit/schematics      12.1.0
@angular/cdk                    12.1.0
@angular/cli                    12.1.0
@angular/language-service       12.1.0
@schematics/angular             12.1.0
rxjs                            6.6.2
typescript                      4.2.3
    
then proceed with installation to your project rather than using -g or --global
The --save option instructs NPM to include the package inside of the dependencies section of your package.json automatically, thus saving you an additional step.
ie;
npm i --save @angular/cli@x.x.x
if you want to use global then,
npm i -g @angular/cli@x.x.x
Reference: What is the --save option for npm install?
 
    
    - 792
- 1
- 9
- 14
