loading...
Cover image for Volta.sh

Volta.sh

mainendra profile image Mainendra ・2 min read

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

Discussion

pic
Editor guide
Collapse
shadowtime2000 profile image
shadowtime2000

Maybe I missed this but does this work on windows?

Collapse
mainendra profile image
Mainendra Author

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

docs.volta.sh/guide/getting-started