How to uninstall n and all node versions installed by n

此生再无相见时 提交于 2019-12-04 01:51:48

You need to manually remove Node versions installed by n and set the correct Node system version.

sudo n prune
sudo npm uninstall -g n
sudo rm -r /usr/local/n
sudo rm /usr/local/bin/node 

See the following issues for n on GitHub:

There have been some changes in n, so I'll provide an updated and longer answer.

First some context. n installs by default to /usr/local. If that is also the location of the "system" install of node and npm then it is overwritten. The cache of previously downloaded versions is kept in /usr/local/n.

Removing cached node versions downloaded by n:

  • n prune removes all but the version matching the active version of node
  • since n v3.0.0, deleting the active version is allowed using n rm <version>
  • (but just manually deleting /usr/local/n is easy and removes the top folder too!)

Removing installed node and npm and npx et al:

  • since n v4.1.0, there is n uninstall. (You will need to reinstall the system node and npm if they were installed to same location and overwritten.)

Uninstalling n itself: if you installed it with npm install n then you uninstall it with npm uninstall n. This does not affect the cached versions of node or the installed version of node, just n. (And there is a small catch-22 if just deleted npm by running n uninstall!)

I'm on mac OSX, so I'm not sure if this is relevant to your use case or not, but it may help.

It looks like n may run into issues if you remove the current version, so I suggest that you delete the folder: /usr/local/n/

Then try to uninstall 'n'. In my case, running npm uninstall -g n did not remove n. Instead, I needed to find the current installation of n by running: which n, then removing that folder from my system.

Then, I would suggest that you use NVM instead. I've found that it's the easiest and most reliable solution that I've found to date.

More specifically, to address your question about how to access the system installation of node, I don't know what OS you are running, but I don't know that there is a system node version.

Typically, you have to manually install node. If there were a system node version, I would expect that it would become outdated very quickly, considering node, and other tools, typically iterate through changes fairly quickly.

I hope this works for you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!