nvm-sh / nvm

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
MIT License
79.05k stars 7.92k forks source link

How to uninstall nvm? #298

Closed mehulkar closed 10 years ago

mehulkar commented 10 years ago

I want to uninstall nvm completely. Is there documentation on how to do this?

ljharb commented 10 years ago

Essentially you'd need to reverse the steps in install.sh - remove any nvm lines from ~/.bash_profile (and/or ~/.profile), rm -rf ~/.nvm, and either reopen your shell, or re-source your bash profile.

However, simply removing the nvm commands from your .bash_profile or .profile should be more than sufficient.

mibamur commented 10 years ago

@mehulkar

just remove directory

rm -rf ~/.nvm
rm -rf ~/.npm
rm -rf ~/.bower

and as ljharb say find and remove line source ~/.nvm from yours .bashrc or .zshrc

@creationix please close this issue

koenpunt commented 10 years ago

@mibamur There is no need for such emphasis in your comments. And it is probably better to use the $NVM_DIR variable, as not everyone has nvm installed in ~/.nvm.

Oneliner:

rm -rf $NVM_DIR ~/.npm ~/.bower
mibamur commented 10 years ago

@koenpunt yeh, you right

mehulkar commented 10 years ago

Thank you!

ljharb commented 10 years ago

To ensure this isn't found by someone unwitting: you do not need to do anything to ~/.npm or ~/.bower - you'll be needlessly blowing away caches.

To uninstall npm with the smallest possible impact, only remove the source lines from your profile. You may also rm -rf $NVM_DIR if you like but it's not necessary.

koenpunt commented 10 years ago

@ljharb Ah you're right, it's about uninstalling nvm, not node. Although by removing the nvm directory you'll remove node as well.

ljharb commented 10 years ago

@koenpunt not if node is also installed globally. I install node from source globally (which is simply running 4 commands in the repo) but use nvm to manage it for my user profile, and I definitely run shells with nvm deactivate so I can use my global node.

scott-joe commented 8 years ago

For additional info, nvm may be installed via Homebrew or npm. Check your installed packages for the proper way to remove the binary files.

ljharb commented 8 years ago

@scott-joe nvm should never be installed via homebrew - it's entirely unsupported. See #469. In addition, the nvm on npm is NOT the correct one, and will not work anyways - see #304.

trusktr commented 8 years ago

What's the reasoning for not hosting nvm on npm? This would make nvm easy to uninstall with npm uninstall -g nvm.

ljharb commented 8 years ago

@trusktr it's not "reasoning", it's that it's a different project that's now deprecated. I've been given ownership of it, and at some point in the future (see #304), I'll replace it with something that bootstraps the proper nvm.

Also, when using nvm, npm is managed by nvm. Uninstalling nvm would delete npm. Why would it make any sense to uninstall nvm with a tool that nvm installed for you?

trusktr commented 8 years ago

It might not make sense. It'd just be nice to uninstall it easily. Maybe it can prompt at the command like something like "This will uninstall versions of node installed by nvm too. Continue?".

trusktr commented 8 years ago

Wait, I'm not even sure that's possible. Oh well, I was able to remove it manually any ways, and I can use Arch Linxu's pacman to see which files don't belong to any package and remove those too.

ljharb commented 8 years ago

it's pretty simple. rm -rf $NVM_DIR and remove the two lines in your profile file.

michaeltyhuang commented 8 years ago

@ljharb it works

ralyodio commented 8 years ago

can we get an nvm uninstall-nvm command?

ljharb commented 8 years ago

@chovy that would require modifying one or more of your profile files, otherwise it'd just be rm -rf "$NVM_DIR" - that's pretty destructive, and not something I'd want to encourage.

Disk space is cheap, so the best way to uninstall it is to simply disable it by removing the sourcing lines from your profile files - which has to be done manually.

jcubic commented 7 years ago

I've removed the directory (on Windows 7) and I still can execute nvm from git bash, what going on?

ljharb commented 7 years ago

@jcubic you may need to restart git bash and/or Windows. Sourced shell functions stay in memory even if the files are deleted.

hzbd commented 7 years ago

step1 - check env:

[root@demo tatia]# echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/.nvm/versions/node/v6.2.2/bin

step2 (remove nvm env from envs):

export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

then, remove /root/.nvm/* done.

ljharb commented 7 years ago

@sconts to uninstall, yes. when installed, however, the nvm paths should be first, or else it won't work properly. (however, nvm unload and nvm deactivate both remove it for you)

myisjon commented 7 years ago

rm -rf $NVM_DIR ~/.npm ~/.bower && unset NVM_DIR

ljharb commented 7 years ago

@myisjon ~/.npm and ~/.bower are for npm and bower, respectively; you don't necessarily want to ~/.npm when removing nvm. (of course, you'll want to remove bower in every case)

FranklinYu commented 7 years ago

How about adding this in README?

cdock1029 commented 6 years ago

Please add uninstall instructions to the README. One preference for using package managers to install node or anything else is ease of removal. Should be explicitly defined somewhere the best practice in completely removing it...

FranklinYu commented 6 years ago

1134 did it, but it has not yet been merged.

ayuthmang commented 5 years ago

Finally, I can fixed it by uninstalling the nvm (previously version is v0.33.11) and install nvm from homebrew (actually I want everything managed with brew) and following the instruction.

By uninstalling using #1134

rm -rf $NVM_DIR ~/.npm ~/.bower

To install nvm via curl (as @ljharb recommended to me brew is not strongly recommended to install nvm)

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash

Now it can solved my problem since last week.

ljharb commented 5 years ago

@blacksourcez nvm is explicitly not supported via homebrew; i strongly suggest removing it and installing it the proper way.

Vadorequest commented 5 years ago

One hard thing to remember is how nvm was installed in the first place. I thought I had used homebrew (glad I didn't), but I used wget instead. I wonder if there is a way to know afterwards how nvm was installed.

I ran into another issue and saw that issue which helped me understand things out. See https://stackoverflow.com/questions/34718528/nvm-is-not-compatible-with-the-npm-config-prefix-option See https://stackoverflow.com/a/54617989/2391795 for how to reinstall nvm

FranklinYu commented 5 years ago

@Vadorequest If everything is in ~/.nvm then it is installed with the official installation script.

dorkmania commented 5 years ago

In addition to rm -rf /root/.nvm if someone accidentally installed nvm as 'root' and is trying to reinstall it as a user you might also want to remove the following lines from /root/.bashrc

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
ljharb commented 5 years ago

Note tho that those lines are safe noops if you’ve deleted the dir.

dorkmania commented 5 years ago

@ljharb export NVM_DIR="$HOME/.nvm" this line in particular wasn't letting me install nvm as a user with wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash even after I deleted the nvm directory and reloaded my shell. I couldn't reboot the server though as it's Production.

ljharb commented 5 years ago

hmm, I’m not sure why a root env var would persist in a non-root session, but fair enough.

FranklinYu commented 5 years ago

@dorkmania You don’t have to reboot, just log in again (as non-root user, of course).

dorkmania commented 5 years ago

@FranklinYu maybe it was just CloudLinux acting weird but I couldn't reinstall even after closing my ssh connection, re-logging in to root and then changing to the user account; till I deleted that line. The script kept giving me a message along the lines of $NVM_DIR set to "/root/.nvm" before stopping. (.nvm was already deleted)

FranklinYu commented 5 years ago

@dorkmania You are not logging into the user account when you first login as root and switch user. The first user matters. Contact your cloud provider if they don’t provide direct access to non-root user login session, or this will bite you here and there.

dorkmania commented 5 years ago

@FranklinYu Makes sense.

lopeselio commented 3 years ago
rm -rf ~/.nvm
rm -rf ~/.npm
rm -rf ~/.bower

works like fine-wine!

CornerstoneII commented 3 years ago

step1 - check env:

[root@demo tatia]# echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/.nvm/versions/node/v6.2.2/bin

step2 (remove nvm env from envs):

export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

then, remove /root/.nvm/* done.

Works like a charm!

xahon commented 3 years ago

It is very inconvenient way. First we need to remove directories and then we need to bother with cleaning up configs manually Why not to make it a special command?

ljharb commented 3 years ago

@xahon it would be very dangerous to mess with your profile files. The most an nvm command could safely do is rm -rf $NVM_DIR, so you'd still end up running a single command, and then manually deleting 2-3 lines from a profile file.

xahon commented 3 years ago

@ljharb fzf has an utility to remove itself in a safe manner. Also user can override NVM_DIR by some reason and it is not safe to do rm -rf $NVM_DIR too

ljharb commented 3 years ago

It’s quite safe; and any user who overrides NVM_DIR would cause nvm to delete the overridden dir anyways, since that’s the only way nvm knows where it lives.

i can’t speak for fzf or any other tool; the current requirements are one rm command, and optionally deleting 2-3 lines from your profile file. There’s nowhere close to enough incremental value from an uninstall command to risk it.

MuhammadUmairMoosani commented 3 years ago

work for me in macos rm -rf ~/.nvm brew cleanup --prune-prefix

molnarjoe commented 2 years ago

I too am trying to remove all of nvm, npm, and node. After following advice above, I don't believe I have completely uninstalled everything. For example, I still see: /usr/lib/node_modules /usr/lib/node_modules/npm/node_modules /usr/lib/node_modules/npm/node_modules/debug/node_modules /usr/lib/node_modules/npm/node_modules/cli-table3/node_modules /usr/lib/node_modules/npm/node_modules/npmlog/node_modules /usr/lib/node_modules/npm/node_modules/request/node_modules /usr/lib/node_modules/npm/node_modules/string-width/node_modules /usr/lib/node_modules/npm/node_modules/node-gyp /usr/lib/node_modules/npm/node_modules/node-gyp/node_modules /usr/lib/node_modules/npm/node_modules/.bin/node-which /usr/lib/node_modules/npm/node_modules/.bin/node-gyp /usr/src/linux-headers-5.11.0-37-generic/include/config/nvm /usr/src/linux-headers-5.11.0-36-generic/include/config/nvm /usr/lib/node_modules/npm

If I want to start afresh with nodejs, what is the advice about removing node_modules and the rest I found? For example the contents of /usr/lib/node_modules/npm/node_modules really concerns me. Ton of stuff...

ljharb commented 2 years ago

@molnarjoe rm -rf /usr/lib/node_modules. I have no idea what /usr/src/linux-headers-5.11.0-36-generic/include/config/nvm is; that's not part of this project whatsoever.

Maxlo27 commented 2 years ago

@mibamur There is no need for such emphasis in your comments. And it is probably better to use the $NVM_DIR variable, as not everyone has nvm installed in ~/.nvm.

Oneliner:

rm -rf $NVM_DIR ~/.npm ~/.bower

then restart your terminal and check🙂

av8ta commented 2 years ago

I wrote a script for the nuclear option of blowing everything away. Yes it's destructive!

Also added option to install volta to manage tools.

https://docs.volta.sh/guide/#why-volta

If you're in an agreeable mood when you run the script you'll end up with node, npm, and nvm gone with volta installed instead.

https://github.com/av8ta/nuke-node