Create-react-app

Previously, setting up a react application was a bit of a hassle since just configuring npm and webpack required quite a lot of time, effort and understanding to get all of the dependencies and plugins up and running.

In the summer of 2016 Facebook released a tool called create-react-app that configures most of everything for you. The article Create Apps with no configuration by Dan Abramov describes how it works and why it exists very well.

However, I have made a short cheat-sheet of the steps to follow below.

There is also a very good article by the Facebook team called Thinking in React which gives you a good idea how react works.

Configure an application from scratch

  1. Install nodejs https://nodejs.org/en/
  2. Open npm command promt in administrator mode.
  3. Install create-react-app globally on machine, type:
    npm install -g create-react-app 
  4. Go into the directory where you want to create your app:
    cd C:\…\CodeProjects 
  5. Create an app using create-react-app called myapp (or anyting you like):
    create-react-app myapp 
  6. Go into the newly created app’s directory:
    cd C:\…\CodeProjects\myapp 
  7. To run the project, type:
    npm start 
  8. To stop the project, type:
    ctrl + c 
  9. To build project for production, type:
    npm build

Configure an existing application

  1. Install node.js https://nodejs.org/en/
  2. Open npm command promt in administrator mode.
  3. Go into the app’s directory:
    cd …/myapp
  4. Install existing modules to project:
    npm install
  5. To run the project, type:
    npm start
  6. To stop the project, type:
    ctrl + c
  7. To build project for production, type:
    npm build

Leave a Reply

Your email address will not be published. Required fields are marked *