7

I have tried to downgrade angular 7 to angular 6 by running the following npm commands:

npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli@6.1.1

However angular/cli 7 version is still displaying in my package.json file. I need help to downgrade angular7 to angular6.

veben
  • 19,637
  • 14
  • 60
  • 80
SaranViji
  • 383
  • 2
  • 6
  • 17
  • In package.json, change the version number in all packages that needs to be downgraded, then run `rm -rf node_modules` to remove everything, then run `npm i` – baao Feb 27 '19 at 07:42

2 Answers2

16

You need to set the version numbers in your package.json for (at least) this packages

"@angular/animations": "^7.0.0",
"@angular/cdk": "7.3.3",
"@angular/common": "^7.0.0",
"@angular/compiler": "7.2.6",
"@angular/core": "7.2.6",
"@angular/forms": "^7.0.0",
"@angular/http": "^7.0.0",
"@angular/material": "7.3.3",
"@angular/material-moment-adapter": "^7.3.3",
"@angular/platform-browser": "^7.0.0",
"@angular/platform-browser-dynamic": "^7.0.0",
"@angular/router": "^7.0.0",
"rxjs": "6.4.0",

as well as in dev-dependencies

"@angular/compiler-cli": "^7.2.6",
"@angular-devkit/build-angular": "0.13.3",
"typescript": "3.2.4",
"@angular/cli": "~7.3.3",

Also make sure to downgrade every library that needs to be downgraded depending on angular's version. Check error messages after step 1...

Once you changed that, run

rm -rf node_modules

from the project's root folder to remove all packages

Then run

npm i 

And you should be good to go

baao
  • 71,625
  • 17
  • 143
  • 203
  • Hi bambam, i have install flexLayout for angular6 but i got following error "Cannot find name 'MediaQueryListEventMap'" i have tried to solve but helped – SaranViji Feb 27 '19 at 09:44
  • check the packages github page to find which version supports angular 6, then change that in your package.json and do the same as described in the answer again, starting from deleting node_modules @SaranViji – baao Feb 27 '19 at 09:45
  • Hi i solved by installed following version " npm install @angular/flex-layout@6.0.0-beta.18" – SaranViji Feb 27 '19 at 09:47
  • Thanks for helping – SaranViji Feb 27 '19 at 09:47
1

I think you forgot the @ before @angular/cli Try these lines to make the change globally.

ng --version

npm uninstall -g @angular/cli
npm cache clean --force

npm install -g @angular/cli@6.1.1
ng --version

Use the same, going to your project folder, and without the -g to make the change locally.

Another way is to manually edit package.json file, remove node_modules folder and re run npm install in your project folder.

veben
  • 19,637
  • 14
  • 60
  • 80