Skip to content

Instantly share code, notes, and snippets.

@WillianTomaz
Last active August 5, 2023 15:34
Show Gist options
  • Save WillianTomaz/4b81d6aee5e22091d15c70be4f3eec0e to your computer and use it in GitHub Desktop.
Save WillianTomaz/4b81d6aee5e22091d15c70be4f3eec0e to your computer and use it in GitHub Desktop.
Instructions for using NVM

Thursday, June 8, 2023

Instructions for using NVM

  • Note:

    • NVM is a version manager for Node.js
  • Was used:

    • Windows 10 (x64)
    • WSL 2 (Ubuntu 20.04.2 LTS)
  • Requirements:

    • CURL (sudo apt-get install curl)


Installation:

Cloning the nvm repository (~/.nvm):

##### Cloning to a specific version
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

##### Or Cloning the latest available version
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash

Populating environment variables:

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"


How to use:

Listing Node versions:

nvm ls

Installing latest version of Node:

nvm install --lts

Checking Node and NPM version:

node -v
npm -v

Installing a specific version of Node:

nvm install v14.17.4
nvm list
nvm use v14.17.4
nvm alias default v14.17.4


Starting Project:

Example running a Node application (already existing):

(run commands inside the project folder)

# Installing project dependencies
npm install
# To build the project
npm run build
# To upload the local application
npm start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment