coreybutler / nvm-windows

A node.js version management utility for Windows. Ironically written in Go.
MIT License
36.68k stars 3.28k forks source link

Implement `nvm switch` command #884

Open xavierfoucrier opened 1 year ago

xavierfoucrier commented 1 year ago

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.

coreybutler commented 1 year ago

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?

xavierfoucrier commented 1 year ago

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 😉

coreybutler commented 1 year ago

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.

github-actions[bot] commented 1 year ago

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.

xavierfoucrier commented 1 year ago

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

micky2be commented 1 year ago

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

noooonee commented 6 months ago

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.