menu

Questions & Answers

Angular version in App-root does not match that of package.json

I downgraded Angular to version 8, everything went fine and in the package.json the version is 8.2.0, but when I look from the console, the version is still 14.0.3.

package.json

{
  "name": "epg",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "prestart": "node aspnetcore-https",
    "start": "run-script-os",
    "start:windows": "ng serve --port 44498 --ssl --ssl-cert %APPDATA%\\ASP.NET\\https\\%npm_package_name%.pem --ssl-key %APPDATA%\\ASP.NET\\https\\%npm_package_name%.key",
    "start:default": "ng serve --port 44498 --ssl --ssl-cert $HOME/.aspnet/https/${npm_package_name}.pem --ssl-key $HOME/.aspnet/https/${npm_package_name}.key",
    "build": "ng build",
    "build:ssr": "ng run epg:server:dev",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^8.2.0",
    "@angular/common": "^8.2.0",
    "@angular/compiler": "^8.2.0",
    "@angular/core": "^8.2.0",
    "@angular/forms": "^8.2.0",
    "@angular/platform-browser": "^8.2.0",
    "@angular/platform-browser-dynamic": "^8.2.0",
    "@angular/platform-server": "^8.2.0",
    "@angular/router": "^8.2.0",
    "bootstrap": "^5.1.3",
    "jquery": "^3.6.0",
    "oidc-client": "^1.11.5",
    "popper.js": "^1.16.0",
    "run-script-os": "^1.1.6",
    "rxjs": "~7.5.5",
    "tslib": "^2.4.0",
    "zone.js": "~0.11.6"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^8.2.0",
    "@angular/cli": "^8.2.0",
    "@angular/compiler-cli": "^8.2.0",
    "@types/jasmine": "~4.0.3",
    "@types/jasminewd2": "~2.0.10",
    "@types/node": "^18.0.0",
    "jasmine-core": "~4.2.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.1.1",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "^2.0.0",
    "typescript": "~4.7.4"
  },
  "overrides": {
    "autoprefixer": "10.4.5"
  },
  "optionalDependencies": {}
}

Angular version with ng version from terminal

Wrong angular version in my console

To downgrade I followed the steps below: npm uninstall -g @angular/cli npm cache clean npm install -g @angular/cli@8.2.0 Did I do something wrong? How can I fix this error? Any tip will be appreciated!

Comments:
2023-01-24 15:42:02
I presume after the downgrade you completely deleted your auto generated node_modules and build folders and re-installed and re-built everything?
Answers(1) :

You just ran npm install -g @angular/cli@8.2.0 that downgraded you angular-cli only.

You missed deleting your existing node_modules folder, and you didn't run npm install that will re-install all your packages with specified version.