Installation - nodenv/nodenv GitHub Wiki

There are many ways to install nodenv. The primary installation methods are documented on the readme; but depending on your setup, an alternative method may be preferred.

Homebrew on macOS (or Linuxbrew on Linux)

https://github.com/nodenv/nodenv#homebrew-on-macos

Basic GitHub Checkout

https://github.com/nodenv/nodenv/blob/master/README.md#basic-github-checkout

ZPlug plugin manager for Zsh

Add the following line to your .zshrc:

zplug "RiverGlide/zsh-nodenv", from:gitlab

Then install the plugin

$ source ~/.zshrc
$ zplug install

The ZPlug plugin will install and initialize nodenv and node-build and it will add nodenv and nodenv-install to your PATH.

Upgrading with ZPlug

To update to the latest nodenv and update node-build with newly released Node versions, update the ZPlug plugin:

$ zplug update RiverGlide/nodenv

npm

While it may seem counterintuitive, nodenv can be installed via npm. This mechanism requires that a version of node and npm are already installed on the system. Most likely, once nodenv is installed, this version will be considered the system node by nodenv.

npm install -g @nodenv/nodenv @nodenv/node-build

Many of the nodenv plugins are also published to npm: https://www.npmjs.com/search?q=%40nodenv

Multi-User Global Install

When working on multi-user systems, sometimes it's nice to have a single global installation of node.js for all to use.

To install nodenv globally for all users on the system, the proper environment variables must be set on login shells. Setting the group ownership allows members of the group to manage nodenv. The steps below create a new group or you can use a pre-existing one. To add a user to this group: usermod -aG nodenv user.

git clone https://github.com/nodenv/nodenv.git /usr/local/lib/nodenv
sudo /usr/sbin/groupadd nodenv
sudo chgrp -R nodenv /usr/local/lib/nodenv
sudo chmod -R g+ws /usr/local/lib/nodenv

Then add the following to /etc/profile.d/nodenv.sh:

export NODENV_ROOT=/usr/local/lib/nodenv
export PATH=$NODENV_ROOT/bin:$PATH

eval "$(nodenv init -)"

# Make sure locally install binaries get priority
export PATH=node_modules/.bin:$PATH

Open a new shell to get all the environment variables, then install a few of your favorite plugins

git clone https://github.com/nodenv/nodenv-update.git "$(nodenv root)"/plugins/nodenv-update
git clone https://github.com/nodenv/node-build.git $(nodenv root)/plugins/node-build

Install your node.js of choice nodenv install 4.5.0 and set it to the global default nodenv global 4.5.0

⚠️ **GitHub.com Fallback** ⚠️