2

Trying to remove a global package and it doesn't seem to be removing it.

$ eslint -v
v1.10.3
$ npm uninstall eslint -g
$ sudo npm uninstall eslint -g
$ eslint -v
v1.10.3
$ sudo eslint -v
v1.10.3
$ which eslint
/usr/local/bin/eslint

You can see that eslint is still at version 1.10.3. Why is this not deleting?

Catfish
  • 18,876
  • 54
  • 209
  • 353
  • Does this answer your question? [Can't uninstall global npm packages after installing nvm](https://stackoverflow.com/questions/47763783/cant-uninstall-global-npm-packages-after-installing-nvm) – Henke Jul 07 '20 at 14:51

1 Answers1

2

Probably what happens is that npm is trying to remove it from one place but you have it still installed somewhere else.

This is a problem when e.g. the npm program uses #!/usr/bin/env node in the shebang line instead of the exact patch to the node binary for which it was installed (common for binary installations of Node) especially when you have many versions of Node installed in many places.

See what is the result of:

which node
which npm
cat `which npm` | head -1
cat `which eslint` | head -1
ls -alp `which npm`
ls -alp `which eslint`
cat $PATH

and try to narrow down the problem.

rsp
  • 107,747
  • 29
  • 201
  • 177
  • `$ ls -alp which eslint lrwxr-xr-x 1 m089269 admin 40 Jan 8 2016 /usr/local/bin/eslint -> ../lib/node_modules/eslint/bin/eslint.js`. I just manually removed it from this directory – Catfish Feb 21 '17 at 17:53
  • npm might be preventing you of uninstalling this module since it is needed by some other else. In my case, I had to remove the "babel-loader" in order to remove the "babel-core" – Alberto S. Sep 03 '18 at 10:01