Cannot uninstall angular-cli

2019-01-23 04: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

回答1:

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 -v



回答2:

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 :)



回答3:

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 ✌️



回答4:

The following approach worked for me:

npm uninstall -g @angular/cli

and

npm cache verify


回答5:

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 - It will clean your npm cache from app data folder under your username. use npm cache verify - It will verify your cache whether it is corrupted or not.
use npm cache verify --force -in order to clean your entire cache from your system.

Note- You can also delete by the following the path - 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 enter link description here



回答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



回答7:

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



回答8:

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



回答9:

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

npm uninstall -g angular/cli
npm cache clean

instead use:

npm uninstall -g @ angular/cli


回答10:

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



回答11:

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



回答12:

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.