5

I've read several tutorials and SO on how to upgrade Angular CLI from 7 to 8. This should be a simple thing to do. No matter what I do when I run ng version I get 7.2.2.

enter image description here

I've tried running uninstall, install, upgrade, using sudo, specifying ng update @angular/cli@^8, @latest. No matter what I get the same result. I'm not getting any errors either.

I'm using Mac 10.14.6 (Mojave)

How can I run a simple upgrade to angular CLI 8?

P.Brian.Mackey
  • 43,228
  • 68
  • 238
  • 348
  • Doesn't `npm install --global @angular/cli` work? It's possible you're inside a directory with its own `package.json` and `ng` runs the local version and you're getting those mixed up. – igg Jan 16 '20 at 16:19
  • That shows that your *global* version is already higher than 7.2.2; it's 7.3.9. No output from the `npm upgrade` command seems suspicious, though. What does `npm list -g --depth 0` show? Are you using the regular registry (`npm config get registry`)? – jonrsharpe Jan 16 '20 at 16:20
  • @IraklisGkougkousis - No. I've already tried this. Same result. If you notice in my screenshot I'm not in an app directory. This is my home directory – P.Brian.Mackey Jan 16 '20 at 16:21
  • normally the `ng update` take care of everything. could you try to run `ng update @angular/cli`, as specify [here](https://update.angular.io/#7.0:8.0), and check for any error. Maybe paste the output in a [pastebin](https://pastebin.com/). – Nicolas Jan 16 '20 at 16:23
  • There was a package.json in my home directory for some reason. I deleted it as it shouldn't exist. Similar result when running `npm install -g @angular/cli`. It just changed the `ng v` output to `7.3.9`. Note, I'm only focused on updating my global angular CLI. I'm not trying to update a project. – P.Brian.Mackey Jan 16 '20 at 16:28
  • If you run `npm install -g @angular/cli` it will just **reinstall** the current version. You have to remove it first. – Reactgular Jan 16 '20 at 16:36
  • This question should be closed. I can no longer reproduce the problem. The laptop with the issue completely crashed and requires a new hard drive. Who knows, maybe the hard drive was the problem all along. – P.Brian.Mackey Jan 17 '20 at 02:09
  • Do you have nvm installed? I could not update from 8 to 10 and after I deactivated nvm it worked. – Gerros Oct 06 '20 at 14:55
  • @P.Brian.Mackey I ran into same issue on Windows machine and it was happening because of different VS Code instances that I kept open and at the same time I was trying to update the angular-cli from Command Prompt. I closed VS Code instance and then I was able to update angular-cli version. – akshayp Jul 11 '23 at 10:10

2 Answers2

8

I've tried running uninstall, install, upgrade, using sudo, specifying ng update @angular/cli@^8, @latest. No matter what I get the same result. I'm not getting any errors either.

That will update the CLI for the package.json in the current directory.

You can update the global package like this:

npm uninstall -g @angular/cli
npm install -g @angular/cli
Reactgular
  • 52,335
  • 19
  • 158
  • 208
  • In my specific case this doesn't work. And I've already tried this. As I mentioned I tried a ton of things. I'm still looking into this. Right now it appears I'm unable to uninstall `ng` globally. See similar issue: https://stackoverflow.com/questions/43070441/cannot-uninstall-angular-cli – P.Brian.Mackey Jan 16 '20 at 16:38
  • 1
    No error. `npm uninstall -g @angular/cli` only outputs `up to date in 0.025s`. Then I run `ng v` and I still see Angular CLI 7.3.9. – P.Brian.Mackey Jan 16 '20 at 16:44
  • Find what `.npmrc` files you have on your drive, and check if any are changing where `npm` places the cache. – Reactgular Jan 16 '20 at 16:51
  • My whole laptop crashed while trying to figure this out. I guess that invalidates my question as I have no way to continue troubleshooting this problem. Apple is replacing the hard drive under Applecare – P.Brian.Mackey Jan 16 '20 at 23:54
  • +1 because I appreciate the help you did offer and you deserve credit for helping me figure some things out. – P.Brian.Mackey Jan 17 '20 at 02:10
0

It maybe be caused since the angular versions in global and spec configs are different. you manually update the packages in your package.json and run npm install, or you can use npm outdated