How To Install React On Mac?
React happens to be an open-source, front-end library that helps develop web applications. It is JavaScript-based that can help the Facebook Team and thus obtain come along in a community of individuals and corporations. Furthermore, it helps get a document that will cover how to install react on the mac operating system.
Prerequisites
This helps in guiding in assuming that can help in using macOS. Before you can start, you can help in coming along with a user account with the help of the installation privileges and thus help in getting unrestricted access, which helps in citing the websites in this document.
Audience:
This document is often referred to with the help in getting anyone who can help in gaining to installing the latest nodejs on your productive mac.
System requirements
macOS >=10.10
4 GB RAM
10 GB free space
Installation Procedure
To install the react tooling we need nodejs and npm. So first let’s understand these are and why we need them.
What is Nodejs, and why do you require to react development?
Node.js happens to be an open-source, cross-platform JavaScript run-time environment that executes JavaScript code outside of a browser. Node.js allows developers who use JavaScript to help develop a wide variety of applications like network applications, command-line tools, web API, web applications.
It would help if you had the nodejs for dev tooling (like local webserver with live reloading features) and dev experience, which can help you require nodejs to run react in production.
What is npm and why do you need to react development?
Npm stands for the node package manager, it comes with a dependency management tool for the javascript applications.
It helps in giving the tools that further help in installing and then libraries and then can help in giving along with other tools that help in supporting the react development.
Let us start with the nodejs installation post-completion over nodejs that can help in installing to create a-react-app command line that can further allow creating a new react project.
Download nodejs – Visit nodejs download page here. Click on the system like macOS Installer to download the latest version of node installable package.
Install nodejs – You can help by clicking on the download node-vxx.xx.xx.pkg ( for example node-v10.15.0.pkg) in the previous step to start the installation, shown below the screen. Please click continue
With the help of clicking and then continuing over the earlier step, you in asking to accept a license, and you need to please click continue.
Please accept the agreement by clicking Agree
Click continue
Click install, which would prompt you for the credentials
Provide username and password and click Install Software
The successful installation can help give the screen that shows the installation’s summary.
To access the node and npm executable from the terminal make sure /usr/local/bin is in your $PATH. You can verify that by running the echo $PATH command in the terminal.
Testing Installation
You can use also a terminal and run the below command to test the node
node -v
You should also get to see the output like below (Note: Your version may vary depending on your date of installing as the nodejs team make an aggressive release but make sure your node version is > v10.0.0)
You can help in opening the terminal and run the below command to test npm
npm -v
You should see an output like below (Note: Your version may vary depending on your date of installing as nodejs team make an aggressive release but make sure your npm version is
>5 )
Install create react app
Establishing the productive react development environment can help in adding the configuration tools like babel, web pack which are difficult to configure for a newbie in react world.
Several tools can help reduce this problem out of which create react app is the easiest and finest tool that comes up with the pre-built production-grade configurations. Moreover, the benefits you gain in the tool help in allowing you to help in altering the configuration by ejecting the create react app.
We will install create-react-app using npm. Then, on the terminal, run the install command shown below.
npm install -g create-react-app
npm install -g
On any successful installation, one can help in giving along with the output like above (note your create-react-app version may be different by the time you run this install command)
Test create-react-app
To test the create-react-app, run the below command
create-react-app –version
Congratulations, you have successfully installed create-react-app
We are running the first Hello World application.
Create react application using the create-react-app hello-react command as shown below
This command help in developing a new folder called the hello-react and thus develop in creating different files and setups the required libraries within the folder and help in making the react project ready to be executed without any additional configuration
Once the project is created, change into the project directory and run the application using the npm start command as shown below
npm start command starts webpack development server which in turn performs all the build process and opens a browser window and loads application URL which runs at http://www.localhost3000.org/ by default.
You will see a beautiful window like the below one, which shows you the react icon and some text.
As discussed, create react app comes with great tooling, one of the productive features is webpack hot reloading, which deploys the change on life and saves the developer lot of time to redeploy and reload work.
Let’s open the project and make some changes to see the experience of this great feature. First, we will go through the project structure to understand the importance of the file created by creating react app.
Open the project created in the previous step in any JS editor, here you see the project is open in vscode editor. On to the left in the explorer section, you see file explorer which shows you several folders and files which were created by create-react-app. Let’sLet’s walk through them.
node_modules: This folder is managed by the package manager (npm) and contains all the project library dependencies. Files in this folder should not be modified as the changes made are not guaranteed to be safe as updating/installing any other library can overwrite the changes made.
public: This folder contains the assets that should be served publicly without any restrictions and contains files like index.html, favicon, manifest.json.
src: This is the folder that contains all your development effort. As a react developer you spent a lot of time in this folder creating components and other sources of code.
Now let’s get into the files inside this folder. To start with index.js is the starting file of this project where the execution of your code starts, this file injects the App component exported from App.js. So all the output you see in the browser is resultant on this file; let’s make some changes to this file; we will edit the existing code with new changes as shown in the below screenshot.
Save the file and switch back to the browser to see the changes deployed and loaded as discussed; this is one of the features of create-react-app to tooling setup.
With new changes, your browser window should look like below.
Uninstall create-react-app
You can uninstall any library or tool setup via npm install can be uninstalled using npm uninstall. Perform the below step to remove create-react-app installed previously
On command prompt run npm uninstall -g @angular/cli
Read Also: