-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nvm uninstall <number> should uninstall all <number>.x.x #1792
Comments
I think it would be very unintuitive if the version matching logic worked any differently for uninstall than for anything else. I suppose i could see an |
You could also prompt user a yes/no question
|
nvm’s commands all work in a noninteractive terminal, so prompting isn’t a feature we have available. |
Then As for the risk of unintended removal, user has already insisted in removing all matching versions by adding |
Maybe |
@fl0w Shell may interpret |
Yes, asterisks will likely never be part of nvm because of the inherent risk with shell globs. |
A workaround is to simply delete the nvm directories for all these versions. For example, to delete all
This may leave parts of your nvm configuration inconsistent though. I tried it and noticed no real problems, but maybe @ljharb can comment on whether this approach is reasonable. |
@jcsahnwaldt please don’t do that; a better approach would be to use |
I'd prefer that myself, but I failed to write a script that works correctly. With which awk / sed / grep / etc. commands would you parse the output of |
I'd probably start with |
Prints In some cases, it may be useful to also get versions that are not installed, but I guess in most cases, the user will only want the installed versions. We would probably have to have another grep in the pipeline. (In the case of |
Ah, that's true. You could use |
Yes, Yeah, I think something like One little thing: When I use a pattern that matches no installed version, |
|
I want to uninstall stale installed node versions from my machine so I try to list first with (note that stale version lines do not contain "->" as I see the pattern): ❯ nvm ls --no-colors | grep -o '^[[:blank:]]*v[0-9]*.[0-9]*.[0-9]*' | tr -d '[[:blank:]]v'
13.2.0
13.6.0 But if I chain with xargs later, don't know why but it results in weird error: ❯ nvm ls --no-colors | grep -o '^[[:blank:]]*v[0-9]*.[0-9]*.[0-9]*' | tr -d '[[:blank:]]v' | xargs -I % nvm uninstall %
xargs: nvm: No such file or directory Hope that nvm will have a way to support uninstalling stale versions. Highly voted for this issue to be resolved soon... |
After some research and tinkering, I found this "solution", inspired by @InNoobWeTrust's approach: nvm ls --no-colors | grep -o '^[[:blank:]]*v[0-9]*.[0-9]*.[0-9]*' | tr -d '[[:blank:]]v' | xargs -p -I % sh -c ". ~/.nvm/nvm.sh && nvm uninstall %" CLICK HERE for a short and long explanation of everything this command does for all the people that are mainly JavaScript devs and don't know a lot about the shell like meThe Short: Lists all node versions, takes all node versions expect the one you're using right now and uninstalls them. Long:
EDIT: Oh and btw, yeah, I would totally love a builtin way to do this, both what the OP asked for and uninstalling all stale versions or at least a range of versions. |
Didn't work on my machine, sadly, still stuck at nvm uninstall... Edit: The '-p' option seems to cause problem on my machine, after removing that option, everything work beautifully.
|
for v in $(nvm_ls 6); do echo nvm uninstall $v; done seems like this works just fine; you can remove the |
This is a feature request.
e.g.
nvm uninstall 6
should remove all6.x.x
versionsThe text was updated successfully, but these errors were encountered: