Skip to content

Latest commit

 

History

History
182 lines (121 loc) · 6.55 KB

InstallationGuideLinuxAndNVM.md

File metadata and controls

182 lines (121 loc) · 6.55 KB

Installation Guide - Linux

What You Will Be Installing

  1. Microsoft Teams
  2. Slack
  3. Git
  4. Node.js (latest) and NPM Packages
  5. Visual Studio Code (Recommended) and Plugins
  6. Chrome or Firefox (Recommended)

Before installing anything, update your package manager. Depending on your linux distro, it could be:

sudo apt update
sudo apt-get update
sudo yum update

Many of the installation steps for Linux will be similar to Mac OS X. You can follow the Mac Installation Guide, with these differences:

1. You will not need to install Xcode or Homebrew

Mac OSX does not come with a package manager out of the box like Linux does. Homebrew is a package manager for Mac, and Xcode is a dependency for Homebrew.

2. You will replace the command brew with your own operating system's command

For example, if you have Ubuntu, you would replace this command

brew install git

with

sudo apt-get install git
# You will probably need sudo

Depending on your Linux distro, you could replacing brew with apt, apt-get, yum or something else.

3. We recommend you install Node.js with NVM

We will be using the latest even numbered version of Node.js, and the default Node.js packages are typically a few major versions behind. A command like e.g. sudo apt-get install -y nodejs will not get you the latest version. NVM will allow you to install the latest version.

Node Version Manager (NVM)

Node Version Manager (NVM) is a version manager for Node.js. That means that it will allow you to manager and install multiple versions of Node.js on your computer. We recommend it if:

  • You are working on a Linux machine
  • You do not have the latest version of Node.js and you have Node.js projects that you wish to maintain
  • You are serious about Node.js development and experienced in working with the command line

This is not for beginners. If you are new to the command line or installing node for the first time, we recommend following the instructions on how to install Nodes.js in the Mac or Windows guide.

These instructions are for Mac OSX, Linux and Windows Subsystem for Linux. If you have Windows without some kind of virtualization of Linux, please look into nvm-windows or nodist.

If you already have Node.js installed

Write down what version of Node.js you have. You can find this out by typing node -v

If you have any existing projects, create a file called .nvmrc your projects' root. Open the file and add your current Node.js version to it. So, for example, if current version of Node.js is 10.22.0, you would type and save the following:

v10.22.0

Finally, before installing NVM, you will need to uninstall your current version Node.js and NPM. How you uninstall depends on your Operating System and how you installed Node.js. For example:

# Newer Versions of Ubuntu and Debian
sudo apt remove nodejs
sudo apt purge nodejs
sudo apt autoremove

# Older Versions of Ubuntu
sudo apt-get remove nodejs
sudo apt-get purge nodejs
sudo apt-get autoremove

# Mac OS X with Homebrew
brew uninstall node

If you installed Node.js on Mac OSX from the Node.js website, there are many more steps involved. See https://stackabuse.com/how-to-uninstall-node-js-from-mac-osx/

Creating a profile file (for Mac OS X users)

NVM writes to a profile file, and Mac OS X does not come with a profile file out of the box. If you do not have a profile file, you will need create one before installing NVM. First, find out which shell you are using.

echo $0

If this returns zsh, see if you have a .zshrc file.

ls -a ~

If you do not see .zshrc listed, create one.

touch ~/.zshrc

If echo $0 returned bash, see if you have a .bash_profile file by running ls -a ~. If you do not see a .bash_profile, create one.

touch ~/.bash_profile

Installing NVM

This will download and install NVM.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

In your terminal, you should see a success message like the following:

Successful NVM installation output in your terminal

Pay attention to the last few lines, beginning with export NVM_DIR="$HOME/.nvm". Double check that what you see here is in your profile file. One of these commands should work. That is, one of these commands should return the contents of the file, instead of an error.

cat ~/.zshrc
cat ~/.bash_profile
cat ~/.bashrc
cat ~/.profile

If you see the export NVM_DIR="$HOME/.nvm" ... at the end of the file, then you know that NVM has been added to your path. If not, you will need to manually add it. Copy all three lines beginning with beginning with export NVM_DIR="$HOME/.nvm". You will need to open each file that exists with nano or another text editor.

nano ~/.zshrc
nano ~/.bash_profile
nano ~/.bashrc
nano ~/.profile

Paste the export NVM_DIR="$HOME/.nvm" ... lines, save and exit. Repeat for each profile file that already exists.

Restart your terminal. Type nvm --version. You should see a version number like e.g. 0.38.0.

Using NVM

You have NVM installed, but you still need to install Node.js. You will need to have the latest stable version of Node installed as of June 2021 (16.3).

nvm install node

If you are working with NVM because you have older Node.js projects, you can install older versions of Node.js by specificizing the version number. For example, if need version 10.22.0:

nvm install 10.22.0

To switch between node versions, you can specify the version.

nvm use node # latest version installed
nvm use 10.22.0 # specific version

If you have a .nvmrc file in your project root, then you do not need to specify the version number from inside your project.

nvm use

However, nvm use will only set the node version in the terminal window that you are working in. When you close your terminal window, it will revert to a default version. Here is how you to set the default version:

nvm alias default node # latest version installed
nvm alias default 10.22.0 # specific version

See more usage instructions and "How to Lock down Your Project’s Node Version Using .Nvmrc Or engines".