We now have a youtube channel. Subscribe!

ReactJS | CLI Commands

ReactJS | CLI Commands


Hello folks! welcome back to a new section of our tutorial on ReactJS. In this section of our tutorial on ReactJS, we will be studying about ReactJS CLI Commands.

Let's learn the basic commands available in Create React App command line application in this tutorial.

Creating a new Application

Create React App provides multiple ways to create React application.

Using npx script

npx create-react-app <react-app-name>
npx create-react-app hello-react-app

Using npm package manager

npm init react-app <react-app-name>
npm init react-app hello-react-app

Using yarn package manager

yarn init react-app <react-app-name>
yarn init react-app hello-react-app

Selecting a Template

Create React App creates React application using default template. Template refers the initial code with certain built-in functionality. There are hundreds of templates with many advanced features that are available in the npm package server. Create React App lets users to select templates through template command line switch.

create-react-app my-app --template typescript

Above command will create a react app via cra-template-typescript package from npm server.


Installing a dependency

React dependency package can be installed via normal npm or yarn package command as React makes use of the project structure recommended by npm or yarn.

Using npm package manager

npm install --save react-router-dom

Using yarn package manager

yarn add react-router-dom

Running the application

React application can be run using npm or yarn command depending on the package manager used in the project.

Using npm package manager

npm start

Using yarn package manager

yarn start

To run the application in a secure mode, set an environment variable HTTPS and set it to true before starting up your application. For example, in the Windows command prompt (cmd.exe), the below command set HTTPS and start the application in HTTPS mode.

set HTTPS=true && npm start


Alright guys! This is where we are going to be rounding up for this tutorial. In our next tutorial, we are going to be studying about ReactJS Building and Deployment.

Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.

Post a Comment

Hello dear readers! Please kindly try your best to make sure your comments comply with our comment policy guidelines. You can visit our comment policy page to view these guidelines which are clearly stated. Thank you.
© 2023 ‧ WebDesignTutorialz. All rights reserved. Developed by Jago Desain