Before we start using React, we need to install the basic tools - Node.js and npm (Node Package Manager). It's like preparing oxygen supplies and fuel before heading into space.
Node.js is a platform that allows you to run JavaScript outside the browser. Traditionally, JavaScript was a language that only ran in browsers, but Node.js changed that by enabling JavaScript to run on servers and in developer tools as well.
For a React developer, Node.js is essential for:
npm (Node Package Manager) is the world's largest software package registry. It's a repository containing thousands of packages and libraries that you can add to your project. Imagine a gigantic catalog of spare parts for spaceships - whatever you need, you'll probably find it in npm.
brew install node1sudo apt update
2sudo apt install nodejs
3sudo apt install npm1sudo dnf install nodejsAfter completing the installation, open the terminal (or command prompt) and verify the installation by typing:
1node -v
2npm -vYou should see version numbers, for example
v16.15.0 for Node.js and 8.5.5 for npm. If you see this information, congratulations! Your spaceship is ready for the journey.Besides npm, there are also alternative package managers you can consider:
Yarn is a package manager created by Facebook that offers faster package downloading and better dependency management.
Installation:
1npm install -g yarnpnpm is an efficient package manager that saves disk space by sharing common dependencies between projects.
Installation:
1npm install -g pnpmIn this course, we'll mainly use npm, but all commands have their equivalents in Yarn and pnpm.
Now that you have Node.js and npm installed, you're ready to create React applications! In the next lesson, we'll learn how to create a new React project using Vite.