Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to uninstall n and all node versions installed by n

Tags:

I have installed some Node.js versions with the tool n. I have uninstalled all Node.js versions using:

sudo n prune 

except the current (activated) version. If I try to unsinstall the current version:

sudo n rm 6.10.2

I get the following error.:

Error: cannot remove currently active version (node/6.10.2).

I can not figure out, how to set the systems (Arch Linux) default Node.js version, which is already installed and was used to install n.

If uninstall n using:

sudo npm uninstall -g n 

it leaves the current version on my computer.

ls /usr/local/n/versions/node/                                                                                                                                                                       6.10.2/ 

Do I need to manually delete the folder: /usr/local/n/? Or, is there an option in n to uninstall it and all the Node.js versions installed by n, so that I get the setting before I installed n?

like image 683
BuZZ-dEE Avatar asked Apr 04 '18 10:04

BuZZ-dEE


People also ask

How do I uninstall all Nodejs?

To completely uninstall node + npm is to do the following: go to /usr/local/lib and delete any node and node_modules. go to /usr/local/include and delete any node and node_modules directory. if you installed with brew install node, then run brew uninstall node in your terminal.

Where does N store node versions?

n downloads a prebuilt Node. js package and installs to a single prefix (e.g. /usr/local ). This overwrites the previous version. The bin folder in this location should be in your PATH (e.g. /usr/local/bin ).

How do I completely remove npm and node from Windows?

Search for Program and features. Under the program and features click on Uninstall a program. Now search for Node. js and uninstall it.

How to install the latest NodeJS version with N?

To install the latest nodejs version with n, simply run: The old version of node will be moved to the new location i.e. /home/ostechnix/.n/bin/node in my case. Open a new shell session or restart the Terminal session to use node version from the new location.

Can I remove the node version installed using NVM?

However, this will not remove the node version installed using NVM or your distributions package manager. It will only remove the node versions that are installed with n.

How to completely uninstall NodeJS and NPM from Windows operating system?

Learn, how to completely uninstall node.js and npm from a Windows operating system. Clear the npm cache by running the following command in your terminal. Go to the windows control panel and click on Uninstall a program, select Node.js and click on uninstall tab to uninstall the node and npm successfully.

How to remove installed versions of N from the system?

If N_PREFIX is not set then n installs to usr/local by default and stores the downloaded versions in /usr/local/n/versions. To remove all the downloaded versions and the directory you can use: If N_PREFIX is set, then delete the "$ {N_PREFIX}/n" directory.


2 Answers

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:

  • Cant uninstall n and node #327
  • Simple command to switch back to the system installation of Node #486
like image 88
BuZZ-dEE Avatar answered Sep 29 '22 05:09

BuZZ-dEE


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 to keep using them 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!)

like image 28
shadowspawn Avatar answered Sep 29 '22 06:09

shadowspawn