Node Version Helper
Project status: planning to archive this project. See https://github.com/shadowspawn/nvh/issues/16.
Easily install Node.js versions. No profile setup required for default install location.
bash (and does not require a working node install).
On Windows the "Windows Subsystem for Linux" is supported, but not "Git BASH".
Forked from tj/n with improvements to syntax, new features, and prototype future changes for
- Node Version Helper
If you already have
node, the easiest way to install
nvh is with
npm install --global @shadowspawn/nvh nvh help
nvh installs node to
/usr/local by default, but you may change this location by defining
NVH_PREFIX (see environment variables). The downloads are written to a cache in subdirectory
To avoid requiring
npm global installs, it is recommended you either install to your home directory using
NVH_PREFIX, or take ownership of the system directories:
sudo mkdir -p /usr/local/nvh sudo chown -R $(whoami) /usr/local/nvh sudo chown -R $(whoami) /usr/local/bin sudo chown -R $(whoami) /usr/local/include sudo chown -R $(whoami) /usr/local/lib sudo chown -R $(whoami) /usr/local/share
npm is not yet available, a way to bootstrap an install:
curl -L https://raw.githubusercontent.com/shadowspawn/nvh/master/bin/nvh -o nvh bash nvh install lts # Now node and npm are available
Installing Node Versions
nvh install <version> to download and install a version of
<version> has already been downloaded,
nvh will install from its cache.
nvh install 8.11.3 nvh i lts
nvh on its own to view your downloaded versions, and install the selected version.
$ nvh node/v8.11.3 ο node/v10.15.0 node/v11.6.0 Use up/down arrow keys to select a version, return key to install, d to delete, q to quit
(You can also use j and k to navigate up or down without using arrows.)
Specifying Node Versions
There are a variety of ways of specifying the target node version for
nvh commands. Most commands use the latest matching version, and
nvh ls-remote lists multiple matching versions.
Numeric version numbers can be complete or incomplete, with an optional leading
8: 8.x.y versions
v6.1: 6.1.x versions
There are labels for two especially useful versions:
lts: newest Long Term Support official release
current: newest official release
There is an
auto label to read the target version from a file in the current directory, or any parent directory.
nvh looks for in order:
.nvh-node-version: version on single line. Custom to
.node-version: version on single line. Used by multiple tools: node-version-usage
.nvmrc: version on single line. Used by
enginesfield to determine compatible
node. Requires an installed version of
node, and uses
npx semverto resolve complex ranges.
There is support for release streams:
carbon: codenames for LTS release streams
These node support aliases may be used, although simply resolve to the latest matching version:
The last version form is for specifying other releases available using the name of the remote download folder optionally followed by the complete or incomplete version. For example:
Using Downloaded Node Versions Without Reinstalling
There are three commands for working directly with your downloaded versions of
node, without reinstalling.
You can show the path to the downloaded version:
$ nvh which 6.14.3 /usr/local/nvh/versions/6.14.3/bin/node
Or run a downloaded
node version with the
nvh run command:
nvh run 8.11.3 --debug some.js
Or execute a command with
PATH modified so
npm will be from the downloaded
npm will be working with a different and empty global node_modules directory, and you should not install global
modules this way.)
nvh exec 10 my-script --fast test
node install normally includes
npm as well, but you may wish to preserve an updated
npx leaving them out of the install using
$ nvh install latest installed : v10.6.0 (with npm 6.1.0) $ npm --version 6.1.0 $ nvh install --preserve v8.0.0 installed : v8.0.0 $ npm --version 6.1.0
You can make
--preserve the default behaviour for installs by setting
Remove the installed version of node and npm:
List matching remote versions available for download:
nvh ls-remote lts nvh ls-remote latest nvh lsr 10 nvh lsr --all
List downloaded versions in cache:
Remove some downloaded versions:
nvh rm 4.9.1 8.15.0
Remove all downloaded versions except the version matching the installed version, or all:
nvh cache prune nvh cache clear
Display diagnostics to help resolve problems:
Optional Environment Variables
nvh command downloads and installs to
/usr/local by default, but you may override this location by defining
To change the location to say
$HOME/.nvh, add lines like the following to your shell initialization file:
export NVH_PREFIX=$HOME/.nvh export PATH=$NVH_PREFIX/bin:$PATH
See Environment Variables for more about these settings:
NVH_MAX_REMOTE_MATCHES NVH_NODE_MIRROR NVH_NODE_DOWNLOAD_MIRROR NVH_PRESERVE_NPM NVH_USE_XZ
See Proxy Server for variables and advice for using a proxy server.
How It Works
nvh downloads a prebuilt
node package and installs to a single prefix (e.g.
/usr/local). This overwrites the previous version. The
bin folder in this location should be in your
The downloads are kept in a cache folder to be used for reinstalls. The downloads are also available for limited use using
nvh which and
nvh run and
npm packages are not changed by the install, with the
npm itself which by default is part of the
nvh is a fork from tj/n, so the original is an alternative!
nvh does not:
- manage the global npm modules per version of node
- dynamically change the available node as navigate in shell
- run natively on Windows or in Git BASH
Alternatives offering different feature sets are: