50

I've tried several times to uninstall my angular-cli in order to update it but even if I follow the instructions provided on github:

  • npm uninstall -g @angular/cli
  • npm cache clean
  • npm install -g @angular/cli@latest

When I check using the command ng --version I still get the old version :

 angular-cli: 1.0.0-beta.26

 node: 7.7.1
 os: darwin x64

How can i fix this issue? Thanks

Sandro Palmieri
  • 1,193
  • 2
  • 12
  • 26
  • 1
    Try to reopen console – yurzui Mar 28 '17 at 13:07
  • I did reopen the console several times...but the issue is still there – Sandro Palmieri Mar 28 '17 at 13:11
  • 4
    As angular/cli was renamed: `npm uninstall -g angular-cli @angular/cli` should do it ... this would all beta versions – Sebastian Hildebrandt Mar 29 '17 at 10:51
  • 2
    I 've just tried your suggestion. It executes the uninstallation but still when I check with ng -v it shows me the old version...it's really frustrating – Sandro Palmieri Mar 29 '17 at 11:39
  • If you're using Angular CLI 1.0.0-beta.28 or less, you need to uninstall angular-cli package first. `npm uninstall -g angular-cli`, `npm uninstall -g @angular/cli`, `npm cache clean`, `npm install -g @angular/cli@latest` – Farhad Aug 21 '17 at 03:50
  • npm uninstall -g @angular/cli npm cache clean --force npm install -g @angular/cli@latest – Jitendra singh Jul 08 '18 at 16:02
  • This is what worked for me on OS X using `nvm` https://stackoverflow.com/questions/53604991/why-does-angular-cli-version-say-1-after-installing-version-7/53618641 – conner.xyz Dec 04 '18 at 17:47

16 Answers16

87

I have also faced the same issue in recent past for me I have do the following commands one by one in terminal.

sudo npm uninstall -g angular-cli
sudo npm cache clean

After this run

ng -v

If still get angular-cli version 1.0.0-beta.2x.x then run the following command

which ng

It will show the ng path. Go to the path and if it is linked with any file remove the same the link and actual ng file. In my case the link is in /usr/bin/ng and actual path of ng file is /lib/node_modules/@angular/cli/bin/ng.

sudo rm -rf /lib/node_modules/@angular/cli/bin/ng
sudo rm -rf /usr/bin/ng

Next you need to install @angular/cli using

sudo npm install -g @angular/cli

Close all the terminal and run ng -v and you are on. May be it will help someone. Thanks :)

sib10
  • 1,104
  • 1
  • 9
  • 15
36

If you are facing issue with angular/cli then use the following commands:
npm uninstall -g angular-cli to uninstall the angular/cli.
npm cache clean to clean your npm cache from app data folder under your username.
use npm cache verify to verify your cache whether it is corrupted or not.
use npm cache verify --force to clean your entire cache from your system.

Note:
You can also delete by the following the paths
C:\Users\"Your_syste_User_name"\AppData\Roaming\npm and
C:\Users\"Your_syste_User_name"\AppData\Roaming\npm-cache
Then use the following command to install latest angular/cli version globally in your system.
npm install -g @angular/cli@latest
To get more information visit github angular-cli update.

cuSK
  • 809
  • 11
  • 26
Prabhat Maurya
  • 1,058
  • 16
  • 21
  • @WastedFreeTime, after uninstall do npm cache verify --force(this flag is required) then install whatever version you want. This worked for me. – Prawin soni Apr 22 '20 at 06:28
  • if following the above answer doesn't work, you may have to redo it and use `--force` flag on `npm cache clean` to make it work. – rgantla Jul 07 '20 at 16:44
  • 1
    I tried all those options, it doesn't work, I have uninstalled Node js, I did delete node folders manually from C:\User\...\AppData\Roaming\ – cvsr.sarma Oct 09 '20 at 03:54
35

Updating Angular CLI

https://github.com/angular/angular-cli#updating-angular-cli

If you're using Angular CLI 1.0.0-beta.28 or less, you need to uninstall angular-cli package first.

npm uninstall -g angular-cli
npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@latest

Then when it gets done successfully you may try:

ng --version

Farhad
  • 533
  • 9
  • 21
14

This sometime happens when you had actually installed @angular/cli using yarn and not npm.

You can verify this by looking in to yarn's global install folder.

You can remove it from yarn using

yarn global remove @angular/cli

Praym
  • 2,038
  • 23
  • 21
  • Thanks a lot. This saved me the crazy search to uninstall the angular cli. – rustygb Mar 22 '20 at 14:40
  • This deserves some more upvotes :) In my case `yarn global remove` refused to do it; I had to delete it manually. Use `which ng` to find out where it was installed. – Vincent Sels Sep 10 '20 at 19:50
9

You are using the beta version of angular CLI you can do this way.

npm uninstall -g @angular/cli
npm uninstall -g angular/cli

Then type,

npm cache clean

Then go to the AppData folder which is hidden in your users and go to roaming folder which is inside AppData then go to npm folder and delete angular files in there and also go to npm-cache folder and delete angular components in there.After that restart your PC and type

npm install -g @angular/cli@latest

This worked for me ✌️

6

I found a solution, first, delete the ng file with

sudo rm /usr/bin/ng

then install nvm (you need to restart your terminal to use nvm).

then install and use node 6 via nvm

nvm install 6
nvm use 6

finally install angular cli

npm install -g @angular/cli

this worked for me, I wanted to update to v1.0 stable from 1.0.28 beta, but couldn't uninstall the beta version (same situation that you desrcibed). Hope this works

Gustavo Topete
  • 1,246
  • 1
  • 9
  • 15
  • 2
    I've tried everything, nothing seemed to work, then I just executed this `rm $(which ng)` and then `npm install -g @angular/cli@latest` and it worked like a charm. So basically I did pretty well without nvm but was forced to remove the ng binary. Bloody hell... – Albert Apr 14 '20 at 18:22
  • thanks alot man. I had nvm installed... Didnt know what was wrong – Ian Samz May 02 '20 at 20:14
  • @Albert : Thanks a lot finally this one works for me – Deepak Pookkote Jan 27 '22 at 17:08
  • For me the path to ng is ``/usr/local/bin/ng`` Use a `which ng` to locate the path. – Alaindeseine Jun 23 '22 at 12:43
6

The following approach worked for me:

npm uninstall -g @angular/cli

and

npm cache verify
Enayat
  • 3,904
  • 1
  • 33
  • 47
1

I had the same problem. This doesn't work:

npm uninstall -g angular/cli
npm cache clean

instead use:

npm uninstall -g @ angular/cli
FelixSFD
  • 6,052
  • 10
  • 43
  • 117
苏俊明
  • 11
  • 2
1

I could not get the angular-cli to go away. I FINALLY figured out a way to find it on my windows machine. If you have Cygwin installed or you are running linux or mac you can run which ng and it will give you the directory the command is running from. In my case it was running from /c/Users/myuser/AppData/Roaming/npm/ng

Jimeh
  • 367
  • 1
  • 6
  • 16
1

Step 1:

npm uninstall -g angular-cli

Step 2:

npm cache clean

Step 3:

npm cache verify

Step 4:

npm cache verify --force

Note: You can also delete by the following the paths

C:\Users"System_name"\AppData\Roaming\npm and

C:\Users"System_name"\AppData\Roaming\npm-cache

Then

Step 5:

npm install -g @angular/cli@latest
  • why copy pasting answer of somebody else w/o any new input and posting as your own? SO should punish for such behavior. – user1927829 Oct 14 '21 at 09:50
1

I had angular-cli version 1.0.0-beta.28.3, and the only thing that worked for me was deleting the angular-cli directly from the global node_modules folder:

cd /usr/local/bin/lib/node_modules
rm -rf angular-cli

After that ng version output was, as expected:

command not found: ng

And I could install the latest angular-cli version:

npm install -g @angular/cli@latest

Hope it helps...

  • I had an old angular-cli version 6 installed, but it could not be upgraded. I needed to delete it on my Mac OS X using `rm -rf /usr/local/lib/node_modules/@angular/angular-cli` Afterwards, I installed the latest cli as usual and it worked fine `npm install -g @angular/cli --latest` – MichaelHuelsen Jul 17 '20 at 21:21
0

You have to use (without @)

npm uninstall -g angular/cli

because

If you're using Angular CLI beta.28 or less, you need to uninstall angular-cli package. It should be done due to changing of package's name and scope from angular-cli to @angular/cli https://github.com/angular/angular-cli

philipooo
  • 1,039
  • 9
  • 17
0

Try to update via these steps found in the npm repo for the angular cli.

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

There is also an angular cli migration guide. One other option (more involved) is to start a new project and migrate over by copying and pasting certain files. This can be found here in the "moving into the cli" section of the angular-cli github

unseen_damage
  • 1,346
  • 1
  • 14
  • 32
0

Check if you have the hidden folder ".npm" in your Home directory and delete the old angular-cli folder.

ej27
  • 13
  • 3
0

While uninstalling Angular CLI I got the same message (as it had some permission issues):

Unable to delete .Staging folder

I tried deleting the .staging folder manually, but still got the same error. I logged in from my administrator account and tried deleting the staging folder again manually, but to no avail.

I tried this (run as Administrator):

npm uninstall -g @angular/cli
npm cache verify
npm install -g @angular/cli.

Then I tried creating the project from my normal user account and it worked.

compor
  • 2,239
  • 1
  • 19
  • 29
gaurav bhatt
  • 23
  • 2
  • 12
0

For those using Windows, I had this issue because :

  • after running npm uninstall -g @ angular/cli, the folder AppData\Roaming\npm were still containing a ng file
  • this file prevented a complete uninstall of the CLI

I tried then to remove the ng file manually, but for some reasons it was not possible (I did not have the right), even as admin.

The only hack I found was using a 'linux based' command (I used Git bash) as admin and removing this file from command line: cd AppData/Roaming/npm rm ng.cmd

For information: this was with the version 6 of the CLI. There is not problem anymore to remove manually this specific file after the update.