To get started, we need to add all the dependencies that are required for an MEVN stack application. We can also refer to the documentation on the official website (https://nodejs.org/) for details on how to install Node.js in any operating system.
Installing Node.js
Installing Node.js on macOS
There are two ways to install Node.js on macOS: using the installer or using the bash.
Installing Node.js using the installer
To install Node.js using the installer, perform the steps:
- Install the installer: We can download the installer for macOS from the official website's download page (https://nodejs.org/en/#download). We will be installing the latest node version, which is 10.0.0. You can install any node version you want, but the application that we will be building in this book will require the node version >= 6.0.0. Run the installer and follow the instructions given. When we download and run the installer, we will be prompted with the following dialog box:
- Just hit Continue until the installation finishes. Once the installation is complete, we will be able to see the following dialog box:
Just hit Close and we will be done.
Installing Node.js using the bash
Node.js can be easily installed using Homebrew in macOS. Homebrew is a free and open source software package manager that is used to install software on macOS. I personally prefer Homebrew because it makes it very easy to install different software on Mac:
- To install Homebrew, type the following command:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Now, use Homebrew to install Node.js with the following command:
$ brew install node
Installing Node.js on Linux
For Linux, we can either install the default distribution of Node.js or we can download it from NodeSource to use the latest version.
Installing Node.js from the default distribution
To install from the default distribution, we can install Node.js on Linux by using this command:
$ sudo apt-get install -y nodejs
Installing Node.js from NodeSource
To install Node.js from NodeSource, perform the following steps:
- First download the latest version of Node.js from NodeSource:
$ curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash
- Then, install Node.js with the command:
$ sudo apt-get install -y nodejs
Installing Node.js on Windows
We can install Node.js on Windows by following these steps:
- Download the Node.js installer from the official website (https://nodejs.org/en/download/)
- Run the installer and follow the given instructions
- Click on the Close/Finish button
Installing Node.js for Windows via an installer is almost the same as on macOS. Once we download and run the installer, we will be prompted with a dialog box. Just click on Continue until the installation completes. When we finally see a dialog with a confirmation, we hit Close. Node.js will be installed!