GitHub picture of ramblehead

Node.js NVM Notes

Collection of Node.js and Node Version Manager (nvm) application hints and resource references. These hints were tested on Ubuntu 22.04 LTS.

Installing nvm on Linux

Automatic Installation via nvm install

To install or update nvm run the following script:

$ # see https://github.com/nvm-sh/nvm for the current version
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

References

nvm bash Environment

Add the following lines to ~/.bashrc (for interactive shells):

export NVM_DIR="${HOME}/.nvm"

# Load nvm
[ -s "${NVM_DIR}/nvm.sh" ] && source "${NVM_DIR}/nvm.sh"

# Load nvm bash_completion
[ -s "${NVM_DIR}/bash_completion" ] && source "${NVM_DIR}/bash_completion"

Add the following lines to /.profile (for login shells):

NVM_DIR="${HOME}/.nvm"

# Load nvm
[ -s "${NVM_DIR}/nvm.sh" ] && source "${NVM_DIR}/nvm.sh"

Installing Node.js via nvm

To list available Node.js versions:

$ nvm ls-remote

To install particular Node.js <version>:

$ nvm install <version>

To list installed Node.js versions:

$ nvm ls

To set default Node.js <version>:

$ nvm alias default <version>

To select current Node.js <version>:

$ nvm use <version>