Nodenv quick commands cheatsheet

nodenv is a great tool to manage multiple NodeJS versions and here are some of its commonly used commands summarized for quick reference.

Install nodenv itself and setup

$ brew install nodenv
# follow the printed instruction and add below entry to ~/.bash_profile
$ nodenv init
$ eval "$(nodenv init -)"

Install/Uninstall node versions

# list all available versions
$ nodenv install -l
# install a specific version
$ nodenv install <version>
# list all installed versions (can also check ~/.nodenv/versions/)
$ nodenv versions
# uninstall a specific version
$ nodenv uninstall <version>

Set/Unset node versions

# will add a .node-version file into current directory
# with version name to override the global version
$ nodenv local <version>
# unset and remove the .node-version file
$ nodenv local --unset

# will write to ~/.nodenv/version as global version
# but it can be overriden by the local one if set above
$ nodenv global <version>

# show the current local node version used
$ nodenv local
# show the current global node version used
$ nodenv global

# set local version to current system Node ($PATH)
$ nodenv local system
# set global version to current system Node ($PATH)
$ nodenv global system

# set NODENV_VERSION env to override both local/global version set above
$ nodenv shell <version>
# unset the NODENV_VERSION env
$ nodenv shell --unset

See official docs for more.

node js nodejs