Can't uninstall global npm packages after inst

2019-03-20 08:41发布

I've found several threads related to this issue but none seem to deal with my case specifically and I've been unable to solve using the suggestions I've found.

When I run npm uninstall -g "some package"

it just returns: up to date in .043s - And the global package remains.

For example I'm trying to uninstall babel-cli and after running npm uninstall -g babel-cli I'm still able to use the cli.

This started after I uninstalled node and npm and reinstalled using nvm. I'm wondering if I missed something while uninstalling node and it's causing the issue. I checked my dot files and noticed I still have a .npm outside of .nvm. Is that normal? Thanks in advance for any suggestions.

标签: node.js npm nvm
3条回答
聊天终结者
2楼-- · 2019-03-20 08:51

I had experienced the same for one of the npm global package and below solution worked for me. Please use sudo before your command to solve this. like sudo npm uninstall -g "some package"

Without sudo: []$ npm uninstall -g truffle up to date in 0.082s

After trying with sudo: []$ sudo npm uninstall -g truffle [sudo] password for shahid: removed 81 packages in 1.902s

[]$:truffle bash: /usr/bin/truffle: No such file or directory

查看更多
Melony?
3楼-- · 2019-03-20 08:54

No matter how many times you call npm uninstall babel,

OR Yarn uninstall -g babel

OR Yarn uninstall -g babel-cli

It does shows updated. And when you check it if it still exists by entering "babel -help"

You get this- > babel still somewhere in your Mac

I know its frustrating. So I found where these files get stored locally and after removing them from local storage, I finally got -> Finally my system doesn't understand what babel is. What we really want

How did I find it:

Finder's search result is not going to give you path of the global babel storage. I found that there is a folder called /usr in in our real-root directory "Macintosh HD" It is hidden

So, Select finder -> Go -> Go to Folder.. And type "/usr".

A new finder window will open and it will show all the files inside it. Now you can roam around and check all the files you installed, some probably forgotten and never got a chance to remove.

Go to usr/local/bin -> and here you will find the files which you globally installed. as shown here - > Directory of shortcuts

Again, as you can see, there are arrow signs on the icons, which indicate that these are just the shortcuts. Deleting them will cut the link, but the files will still be there somewhere.

To delete the files, right click on the icon and select "Show Original"

You will be redirected to a folder where you will find babel.js file.

Remember, its again just one file. To completely remove the babel-cli, select the column view in the finder, and you can scroll left and check its parent directories. And here is where the actual installations are done.

finalpath part 1

finalpath part 2

You can see, just like basic node modules that gets installed in our local web projects, babel-cli and similar such packages gets installed in similar format but in these global location.

Now you can right-click the babel-cli folder and move it to trash.

Hope the hunt is finally over.

查看更多
Deceive 欺骗
4楼-- · 2019-03-20 08:55

(nvm maintainer here)

The list of things that you can npm uninstall -g is available at npm ls -g --depth=0. If you don't see the thing you want to uninstall there, but you can still access it, then if it was npm-insatlled, it was probably installed with your system version of node.

You can quickly verify this with nvm use system && npm ls -g --depth=0. If you see the package there, then while using the system version, you can npm uninstall -g it.

查看更多
登录 后发表回答