React - Installing Node.js
Guide to installing Node.js
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. It allows you to run JavaScript on the server side and is essential for developing and building React applications. This guide provides step-by-step instructions on how to install Node.js on different operating systems.
Key Points:
- Node.js is required for running and building React applications.
- Node.js includes npm (Node Package Manager) for managing packages and dependencies.
- You can install Node.js using the official installer or a package manager.
Installing Node.js on Windows
- Visit the official Node.js website: https://nodejs.org
- Download the Windows installer by clicking the "LTS" version button.
- Run the installer and follow the prompts in the installation wizard.
- Ensure that the "Add to PATH" option is selected during the installation.
- Verify the installation by opening a command prompt and running:
node -v npm -v
Installing Node.js on macOS
Using the Official Installer
- Visit the official Node.js website: https://nodejs.org
- Download the macOS installer by clicking the "LTS" version button.
- Run the installer and follow the prompts in the installation wizard.
- Verify the installation by opening a terminal and running:
node -v npm -v
Using Homebrew
- Open a terminal.
- Install Homebrew if it is not already installed by running:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install Node.js by running:
brew install node
- Verify the installation by running:
node -v npm -v
Installing Node.js on Linux
Using a Package Manager
The installation instructions vary depending on your Linux distribution. Here are the commands for some common distributions:
Ubuntu
- Open a terminal.
- Update the package index and install Node.js and npm:
sudo apt update sudo apt install nodejs npm
- Verify the installation by running:
node -v npm -v
Fedora
- Open a terminal.
- Install Node.js and npm:
sudo dnf install nodejs npm
- Verify the installation by running:
node -v npm -v
Arch Linux
- Open a terminal.
- Install Node.js and npm:
sudo pacman -S nodejs npm
- Verify the installation by running:
node -v npm -v
Using Node Version Manager (NVM)
Node Version Manager (NVM) is a popular tool for managing multiple versions of Node.js on a single machine. It is available for macOS, Linux, and Windows (using WSL).
- Install NVM by running the following command in your terminal:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
- Close and reopen your terminal, then verify the installation by running:
command -v nvm
- Install the latest LTS version of Node.js:
nvm install --lts
- Verify the installation by running:
node -v npm -v
Summary
In this guide, you learned how to install Node.js on different operating systems, including Windows, macOS, and Linux. Node.js is essential for developing and building React applications, and installing it correctly is the first step to getting started with React. You also learned how to use Node Version Manager (NVM) to manage multiple versions of Node.js on a single machine.