nvm-windows icon indicating copy to clipboard operation
nvm-windows copied to clipboard

Implement `nvm switch` command

Open xavierfoucrier opened this issue 3 years ago • 7 comments

Just a suggestion / idea, when working with NVM on multiple projects where NodeJS versions differs, it would be nice to have a simple command to easily "switch" between current NodeJS used version and the previous one.

Implementation example:

cd ./project-a
nvm use 18

cd ../project-b
nvm use 16

cd ../project-a
nvm switch  <-- switch to NodeJS v18

Note that nvm switch should do nothing if current/previous versions are the same, which is the case when called the first time.

xavierfoucrier avatar Nov 18 '22 16:11 xavierfoucrier

Correct me if I'm misinterpreting, but it seems like the value of this proposal is not needing to know what the prior version was... i.e. less mental overhead.

One of the planned features for Runtime are aliases, i.e. nvm use myprojectalias. Alternatively, many folks have requested .nvmrc support to automatically switch based on whatever is defined in the .nvmrc file within a project directory. I've been steadfast about not adding this to NVM4W, but I believe there is a place for it (or similar solution) in Runtime.

Bottom line, does your vision of switch concept offer something one of these other solutions doesn't?

coreybutler avatar Nov 18 '22 16:11 coreybutler

Hello @coreybutler!

Thanks for your fast reply. Of course I can confirm that it's just for less mental overhead when working on two or more projects.

I didn't know that you have planned to build an alias feature, looks like a good plan! May be this could fit my needs to easily switch between Node versions.

It's just a proposal / idea that came to me when using NVM a day long. If you think it's out of scope or useless, feel free to close it 😉

xavierfoucrier avatar Nov 20 '22 23:11 xavierfoucrier

Reducing mental overhead is not useless or out of scope. I just wanted to clearly define the challenge so the best solution surfaces. Whether it will be a switch statement or something else can be tested in early Runtime betas. I'll leave this open for further comments.

coreybutler avatar Nov 21 '22 00:11 coreybutler

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Feb 21 '23 02:02 github-actions[bot]

Just leaving a comment to prevent this from closing by @github-actions 😉

xavierfoucrier avatar Feb 21 '23 08:02 xavierfoucrier

For anyone interested in a pseudo solution, I just spend a couple of hours writing a PowerShell script

This is for my personal use, but feel free to give it a try

micky2be avatar Jun 13 '23 20:06 micky2be

I also want to have a quick way to switch multiple projects. How about store project related information in a hidden sub-folder? Link reusable resources to a local repo -- Sound like how python venv been designed.

noooonee avatar Jan 31 '24 13:01 noooonee