DEV Community

Cover image for Volta.sh
Mainendra
Mainendra

Posted on

Volta.sh

Volta - node version manager on steroids

Installation

curl https://get.volta.sh | bash
Enter fullscreen mode Exit fullscreen mode

This will install volta library under ~/.volta directory and also update your ~/.bashrc, ~/.zshrc and ~/.config/fish

Script will add bin directory to path, something like

export VOLTA_HOME="$HOME/.volta"
export PATH="$VOLTA_HOME/bin:$PATH"
Enter fullscreen mode Exit fullscreen mode

Uninstallation

You have to manually remove volta references from your system.

  1. Remove volta from path from your bash or zsh config (~/.bashrc and / or ~/.zshrc)
  2. Removed ~/.volta folder. rm -rf ~/.volta

Volta Commands

    fetch          Fetches a tool to the local machine
    install        Installs a tool in your toolchain
    uninstall      Uninstalls a tool from your toolchain
    pin            Pins your project's runtime or package manager
    list           Displays the current toolchain
    completions    Generates Volta completions
    which          Locates the actual binary that will be called by Volta
    setup          Enables Volta for the current user / shell
    help           Prints this message or the help of the given subcommand(s)
Enter fullscreen mode Exit fullscreen mode

Install node engines

You have to install node using volta install command. You can install as many node versions as you like.

Install latest LTS release

volta install node
Enter fullscreen mode Exit fullscreen mode

Install specific version

volta install node@12
volta install node@12.2.0
Enter fullscreen mode Exit fullscreen mode

Package manager to install local dependencies (package.json)

volta install npm
volta install yarn
Enter fullscreen mode Exit fullscreen mode

Pinning Node engines for your project

To use specific node or npm version for your project use pin command. It will update your package.json file.

volta pin node@12.2.0
volta pin npm@6.14.8
Enter fullscreen mode Exit fullscreen mode

package.json

...
  "volta": {
    "node": "11.14.0",
    "npm": "6.14.8"
  }
...
Enter fullscreen mode Exit fullscreen mode

Global packages

To install global packages (similar to npm install -g) use install or fetch commands
To uninstall global packages (similar to npm uninstall -g) use uninstall command.

e.g.

volta install surge
volta fetch surge
volta uninstall surge
Enter fullscreen mode Exit fullscreen mode

install - install and set the default version of tool
fetch - fetch tool locally without setting it as default

neovim

You have to update node host in init.vim for neovim

let g:node_host_prog = system('volta which neovim-node-host | tr -d "\n"')
Enter fullscreen mode Exit fullscreen mode

Top comments (6)

Collapse
 
mainendra profile image
Mainendra

I would suggest using asdf instead. It's all in one multiple runtime version manager. dev.to/mainendra/asdf-what--2p20

Collapse
 
samarpanda profile image
Samar Panda

Wondering if you recommend to uninstall nvm while using volta?

Collapse
 
mainendra profile image
Mainendra

You don't need to uninstall nvm but if you want you can. Volta installer will update your bashrc or zshrc to use node installed by volta. It will override node path installed by nvm.

Collapse
 
marianzburlea profile image
Marian Zburlea

$ npm rm -g volta

up to date, audited 1 package in 63ms

found 0 vulnerabilities

~ ⌚ 17:16:52
$ yarn rm -g volta
zsh: command not found: yarn

~ ⌚ 17:16:58
$ brew uninstall volta
Uninstalling /opt/homebrew/Cellar/volta/1.0.8... (12 files, 13.5MB)

~ ⌚ 17:17:06
$ volta
zsh: command not found: volta

~ ⌚ 17:17:11
$

Collapse
 
shadowtime2000 profile image
shadowtime2000

Maybe I missed this but does this work on windows?

Collapse
 
mainendra profile image
Mainendra

I’ve not tried on windows but it has windows installer that you might want to try 😬

docs.volta.sh/guide/getting-started