Skip to content

Instantly share code, notes, and snippets.

@justinmklam
Last active October 19, 2019 17:14
Show Gist options
  • Select an option

  • Save justinmklam/1d7aa0738f6b659bf37e354f58d1c6db to your computer and use it in GitHub Desktop.

Select an option

Save justinmklam/1d7aa0738f6b659bf37e354f58d1c6db to your computer and use it in GitHub Desktop.
Instructions to install Node.js on linux

Background

Although sudo apt install nodejs works, it's not recommended because there will be permission issues when trying to install packages globally (ie. npm install -g sass).

A better way to install Node.js is to use Node Version Manager (nvm).

Installing with NVM

# Check the github page for the latest version
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash

# Need to source profile so nvm is reloaded in current terminal. Or just start a new terminal
source ~/.profile

# Installs the latest version of Node.js and npm
nvm install node

# Check the version
node -v
npm -v

# Check the paths
which node
which npm

# Optional: Add node to sudo path (otherwise `sudo node` doesn't work)
echo "alias sudo='sudo env PATH=$PATH:$NVM_BIN'" >> ~/.bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment