[node.js] Cannot uninstall angular-cli

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

This question is related to node.js angular npm

The answer is


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


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


The following approach worked for me:

npm uninstall -g @angular/cli

and

npm cache verify

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.


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


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


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


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


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


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.


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


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


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

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


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

npm uninstall -g angular/cli
npm cache clean

instead use:

npm uninstall -g @ angular/cli

Examples related to node.js

Hide Signs that Meteor.js was Used Querying date field in MongoDB with Mongoose SyntaxError: Cannot use import statement outside a module Server Discovery And Monitoring engine is deprecated How to fix ReferenceError: primordials is not defined in node UnhandledPromiseRejectionWarning: This error originated either by throwing inside of an async function without a catch block dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac internal/modules/cjs/loader.js:582 throw err DeprecationWarning: Buffer() is deprecated due to security and usability issues when I move my script to another server Please run `npm cache clean`

Examples related to angular

error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class error TS1086: An accessor cannot be declared in an ambient context in Angular 9 TS1086: An accessor cannot be declared in ambient context @angular/material/index.d.ts' is not a module Why powershell does not run Angular commands? error: This is probably not a problem with npm. There is likely additional logging output above Angular @ViewChild() error: Expected 2 arguments, but got 1 Schema validation failed with the following errors: Data path ".builders['app-shell']" should have required property 'class' Access blocked by CORS policy: Response to preflight request doesn't pass access control check origin 'http://localhost:4200' has been blocked by CORS policy in Angular7

Examples related to npm

What does 'x packages are looking for funding' mean when running `npm install`? error: This is probably not a problem with npm. There is likely additional logging output above Module not found: Error: Can't resolve 'core-js/es6' Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist` ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.2.0 but 3.2.1 was found instead DeprecationWarning: Buffer() is deprecated due to security and usability issues when I move my script to another server Please run `npm cache clean` What exactly is the 'react-scripts start' command? On npm install: Unhandled rejection Error: EACCES: permission denied Difference between npx and npm?