nvm icon indicating copy to clipboard operation
nvm copied to clipboard

nvm should check for the current npm version when resetting

Open adssib opened this issue 8 months ago • 6 comments
trafficstars

Suggested Improvement for nvm: Prevent Redundant Node Version Switches

It would be helpful for nvm to perform a check when the user attempts to "reset" the Node version that is already active. This would prevent redundant operations and improve the overall user experience.

Example:

  1. The user switches to a Node version using:
   nvm use 20.18.11
  1. If the user attempts to run the same command again, instead of repeating the process, nvm should notify the user that the version is already active.
Error: Node.js version 20.18.11 is already active.

adssib avatar Mar 12 '25 02:03 adssib

In what way does it not already work like this?

ljharb avatar Mar 12 '25 03:03 ljharb

Can you also confirm you’re not using any LLM? LLM-based contributions aren’t clearly legally permitted in an open source project due to licensing provenance concerns.

ljharb avatar Mar 12 '25 03:03 ljharb

I only used LLM in the bug report

adssib avatar Mar 12 '25 03:03 adssib

In what way does it not already work like this?

No it does not check the current version

if you do the same command twice it will re do the whole process again

it does not throw the error thats for sure what happens

adssib avatar Mar 12 '25 03:03 adssib

It shouldn’t throw an error - the user asked for a command to be run in a version, so that’s what should happen. It’s a reasonable optimization to noop the “use” if that version is already in use, though.

ljharb avatar Mar 12 '25 05:03 ljharb

It shouldn’t throw an error - the user asked for a command to be run in a version, so that’s what should happen. It’s a reasonable optimization to noop the “use” if that version is already in use, though.

Yeah thats my intention to add a logic that will check if the user requested version is currently used

this will help with avoiding unnecessary switching of versions

My intention was just to add a check that will see if the requested versions is actually right now set

if so display a message, call an error or whatever

If you're interested in having this feature added to the tool, let me know, and I'd be happy to continue working on it.

adssib avatar Mar 12 '25 05:03 adssib