View All
View All
View All
View All
View All
View All
View All
View All
View All
View All
View All
View All
View All

How to Install React on MacOS? A Step by Step Guide

By Pavan Vadapalli

Updated on Jun 05, 2023 | 8 min read | 6.8k views

Share:

Introduction to React

React is a free JavaScript library used to develop user interfaces for web applications. You must be wondering what is a JavaScript library. JavaScript libraries consist of pre-existing codes written in JavaScript. These codes can be utilised for carrying out commonly occurring tasks in JS. 

The React setup is easy, and it also helps web developers avoid the tedious and often redundant process of writing codes from scratch. It is in charge of streamlining the development of intricate and interactive applications by enabling web developers to create reusable UI components. 

Web developers often use this framework to develop desktop, mobile, and web apps- which is why, today, we bring you an easy installation guide for getting started with React on your MacOS.

After installing React and starting your journey to build dynamic interfaces, you can further enhance your skills by signing up for the Full Stack Software Development Bootcamp by upGrad and mastering the art that is development!

Check out our IT free courses to get an edge over the competition.

Why choose React for web development?

While web developers frequently use React as it is easy to use, various other aspects are at play. Here is a quick list of the several benefits of the React setup:

  • The architecture of React being component-based is one of the reasons. This implies that web developers can break the UIs into smaller, reusable code units. This feature of React makes maintenance seamless and manageable, especially when working on high-stakes and large projects. 
  • The latest upgrades have made the React setup suitable for building not only web applications but also mobile applications for IOS and Android. 
  • Developer tools have now made it easier to edit React code. These tools enable programmers to examine the React component hierarchies in the virtual DOM and make changes per their needs. 
  • The conventional JavaScript frameworks are not easy when it comes to dealing with Search Engine Optimisation (SEO). This is why applications often do not rank well on search engines. React.js applications, on the other hand, can be more easily navigated and indexed by various search engines by enabling server-side rendering of applications. 
  • Testing codes has been made easy with the advent of React.js. Web developers install React.js to debug codes as and when needed. 
  • React is fairly easy to learn. Ample online resources help web developers learn it within just a few weeks. This makes it a popular choice among web developers. 

To be adept in web development and software development, enrol in the Executive Post Graduate Programme in Software Development by upGrad today! 

Check Out upGrad’s Software Development Courses to upskill yourself.

Prerequisites for installing React on MacOS

Installing React on MacOS is simple but comes with a few prerequisites. Here is a checklist you must keep handy before installing React on MacOS:

  • System storage of at least 10GB. 
  • RAM of 4GB. 
  • The latest operating system installed- 10.10 and above. 
  • Speedy internet connection. 

Installing Node.js and NPM

Before delving deeper into the installation of Node.js and NPM, let us break down what they actually are. Node.js is a cross-platform and open-source JavaScript library that can run web apps outside the client’s browser. 

NPM, on the other hand, is the package manager for Node.js and enables open-source web developers to borrow and lend app development packages. 

You need to fulfil a few requirements to download Node.js and NPM on your Mac operating system. You must know the nitty-gritty of the terminal application on your Mac. The next thing you will have to do is, install Homebrew on your device to install Node, avoiding security issues. 

Now, let’s get started!

  • The first step is to start the terminal app and writebrew update’. By doing this, your Homebrew application will be updated with the latest editions of Node. 
  • The next step is to write ‘install node’. After this, Homebrew will download files and get them installed in your system. 
  • Check if both Node and NPM have been successfully downloaded into your system by running the following command:

-Type node -v on the terminal to check if the latest version of Node has been downloaded to your system. 

-Type npm -v to check if the latest version of NPM has been downloaded to your system. 

Understanding the Create-react-app tool

The Create-react is a catalyst when it comes to seamlessly starting React applications on your system. The Create-react app (CRA) automates the process of configuration of files and installation and configuration of build tools. This saves developers a lot of time and effort that they can utilise by focusing on writing codes and building their applications. Here are some of the features of the CRA:

  • A pre-configured development environment with tools like Webpack and Babel
  • A default project structure and organisation
  • A development server with hot reloading for easy development
  • Support for modern JavaScript features like ES6 modules and async/await
  • Automatic code splitting and chunking for faster page loads
  • Built-in support for CSS and Sass

Installing React using Create-react-app

Configuring React manually is a tedious and complicated task. With the help of the Create-react app, you can develop a new React application locally. It automatically handles all the package installations and configuration for us, further simplifying the process. 

A few requirements must be fulfilled before installing React using the Create-react app. You must have a Node version of 8.10 and above and an NPM version of 5.6 and above. Check out how you can install React js using the Create-react app npm:

  • The first step is to install Node.js on your system. You can download the installer for macOS from the Node.js website. 
  • After successfully installing Node.js, open your terminal and run the following command to install the create-react-app:

npm install -g create-react-app

This command will install create-react-app on your system, and by using this, you will be able to create new React projects on your system.

Setting up a new React project on MacOS

The next step is to set up a new React project on MacOS. Here’s how you should go about it:

  • Once create-react-app is installed, create a new React project by typing out the following command:

create-react-app my-app

You may replace ‘my-app’ with the name of your project. For example, myreactproject1

Running a React app on MacOS

The final step is to run the app on your device. Here’s how you will do it:

  • After successfully creating the project, navigate into the project directory by writing down the code given below:

Cd my-app

  • The next and final step is to start the development server by running the following command:

Nmp start

This will start the development server and open your project on your browser. 

Exploring the React file structure

Focus on structuring your React file a certain way for the best outcomes. A simple React folder can be structured in the following manner:

Src directory: The application’s source code is contained in the Src directory. The components 

Components directory: Within the src directory, there is the component directory. The component directory stores all the reusable parts that make up the application. 

Pages directory: The pages directory has different application pages, each with its own directory. 

Index.js file: The component for each page is exported in the index.js file for that page. To create their UI, pages can import components from the components directory.

Utils directory: The programme’s utility files, such as api.js and helpers.js, are located in the utils directory. 

Assets directory: The assets directory stores pictures, font files, and everything that does not relate to coding. 

App.js: The programme’s root component, App.js, is the application’s entry point.

Index.js: The React application is mounted to the DOM in index.js.

Coverage of AWS, Microsoft Azure and GCP services

Certification8 Months
View Program

Job-Linked Program

Bootcamp36 Weeks
View Program

This is one possible React file structure. However, it can be structured in multiple ways based on each project’s unique needs. 

Tips for getting started with React on MacOS

There are a few things that you must keep in mind before getting started with React on MacOS. Here are a few tips:

  • You must have a strong internet connection before installing React on your device.
  • Have a sound knowledge of the command line interface (CLI) on your Mac. React needs you to use CLI commands. 
  • Have a code editor installed. There are various code editors like Visual Studio Code, Sublime Text etc. Choose a code editor that suits you and install it on your device. 
  • Research well on the various versions of React. 
  • Finally, patiently wait for the installation process to complete and follow the instructions well. 

Conclusion

Mac is a great option for web developers to create React-based applications. With our in-depth guide, you’ll be able to install and initiate creating optimised web applications within no time! 

If you have a background in computer science and want to upskill yourself due to the changing needs of the current job market, you must opt for the Master of Science in Computer Science by upGrad. This programme is best suited for individuals who want to bag lucrative opportunities as software or backend engineers, enabling them to access leading tech roles in the long run!

Frequently Asked Questions (FAQs)

1. Can we use React to build mobile apps on Mac?

2. Is using a package manager like Homebrew to install React on Mac mandatory?

3. How can I debug React on my Mac?

Pavan Vadapalli

899 articles published

Get Free Consultation

+91

By submitting, I accept the T&C and
Privacy Policy

India’s #1 Tech University

Executive PG Certification in AI-Powered Full Stack Development

77%

seats filled

View Program

Top Resources

Recommended Programs

upGrad

AWS | upGrad KnowledgeHut

AWS Certified Solutions Architect - Associate Training (SAA-C03)

69 Cloud Lab Simulations

Certification

32-Hr Training by Dustin Brimberry

View Program
upGrad

Microsoft | upGrad KnowledgeHut

Microsoft Azure Data Engineering Certification

Access Digital Learning Library

Certification

45 Hrs Live Expert-Led Training

View Program
upGrad

upGrad KnowledgeHut

Professional Certificate Program in UI/UX Design & Design Thinking

#1 Course for UI/UX Designers

Bootcamp

3 Months

View Program