volta-cli / volta

Volta: JS Toolchains as Code. ⚡
https://volta.sh
Other
11.09k stars 235 forks source link

Can I unload or un-use volta, or use the system provided binaries (whatever they are) #1899

Closed sandermarechal closed 1 month ago

sandermarechal commented 1 month ago

I am working on adding Volta in a project. But it's going to take time. So one branch of my project uses Volta with a new Node version, but all the other branches need to use the system version of Node. How can I unload or un-use the Volta version when I switch branches?

sandermarechal commented 1 month ago

It would be great if I can do something like volta use system or something

charlespierce commented 1 month ago

Hi @sandermarechal, Volta should already fall back to the system Node if there isn't a pinned version. The current process for determining which Node version to use is:

  1. If there's a version pinned in the package.json, use that.
  2. If not, use Volta's default (which is set when you run volta install)
  3. If there isn't a default version, fall back to the system default (i.e. whatever exists without Volta)

So if you haven't set a Volta default with volta install node@<version>, then that should already be the behavior. If you have set one, we don't currently have a CLI way to unset it, however you should be able to do it manually be deleting the file $VOLTA_HOME/tools/user/platform.json. You can also use Volta as the default "system" Node in those situations, updating the version by running volta install node@<version> when needed. (Note: We know that install is a poor verb for the command that actually selects a default version, I have an RFC up right now to change that to make it more intuitive & clear).

If you don't want to remove the default or use Volta-managed default, there is also an environment variable VOLTA_BYPASS that you can set to 1 in order to effectively bypass all of Volta's logic. In that case, however, it will always use the system default and won't even look for a pinned version in package.json.

Do any of those approaches work for you?

sandermarechal commented 1 month ago

Hi @charlespierce. We just used volta to install the same node version as the system version and use it as default, and only put the updated node version in the package.json of the new branch. That worked fine for our purposes. Thanks!