ReactJS Installation/Environment Setup

      In this section, we will learn how to set up a successful environment for React development, For running any react application, we first need to install a node.
      After successful installation of Node, you can install React in two ways,

1) using create-react-app
2) using webpack & babel

      Let’s discuss React Installation using create-react-app in this article…webpack & babel we can discuss in the future.

1)React JS installation using create-react-app:

      NodeJS and NPM are the platforms essential to create & run any ReactJS application. You can install NodeJS and NPM package manager by the link given below.

      ‘create-react-app'(CRA) is a tool created by developers at Facebook & its platform-independent.CRA gives you a massive head start when building React applications. It saves you from time-consuming setup and configuration. we simply run one command and Create React App sets up the tools you need to start your React project.
To use the create-react-app following are required to be installed on your system.

node version >=8.10 node -version
npm version>=5.2 npm -v

Now let us check the current version of Node and npm in the system.

Run the following command to check the Node & NPM version in the command prompt.

1)node version: node -v

2)NPM version: npm -v

i)React Installation using npm:

      npm is a node package manager which will manage everything required for creating your react project.

        $terminal>npm install -g create-react-app

this will install the react globally.

Now you can create your react app,

       $terminal>create-react-app react-first-app

ii)React Installation using npx:

      You can combine the above two steps into a single command using npx.
      The npx is a package runner tool that comes with npm 5.2 and above version.

      $terminal>npx create-react-app react-first-app

#How to Run react Application:
      To run react application we need to move into the folder using the ‘cd’ command and then type npm start.

  • cd my-react-first-app
  • npm start

#React Production Build:

if we want to make the project for the production mode, we use the below command. This command will generate the production build. we can deploy this build on our server to run the application on the host.

  • npm build

Leave a Reply