002 - Create Basic Project - New Project, Empty Project, Existing Project

1. Create a basic project

  You can use the create-react-app package or create an empty IntelliJ IDEA project and install React in it. create-react-app project address: https://github.com/facebookincubator/create-react-app

1.1. Use create-react-app to generate React applications [the first]

  create React App is the recommended way to start building a new React Single Page Application. So your development environment is pre-configured to use webpack, Babel, ESLint and other tools. Learn more about how to install React and create React apps from the React official website .

1" Globally install create-react-app

  Open the built-in terminal (View | Tool Windows | Terminal) and type npm install -g create-react-app at the command prompt.

2" Create an application

  1》File→New→Project→New Project

  2" Select the Static Web option, select the React APP project,

  3" Specify the project name and storage path, and select the appropriate nodejs version in the Node Interpreterfield

  4" In the create-react-app field, specify the path of the create-react-app package.

    Note: Names can no longer contain capital letters

    

After successful creation, 

  above sea level start
    Starts the development server.

  npm run build
    Bundles the app into static files for production.

  above sea level test
    Starts the test runner.

  npm run eject
    Removes this tool and copies build dependencies, configuration files
    and scripts into the app directory. If you do this, you can’t go back!
 We suggest that you begin by typing:
 cd test_react_app above sea level start
 Happy hacking! Done

Directory Structure

  

  Note: To download project dependencies, do one of the following:

    Open Terminal (View | Tool Windows | Terminal) and type npm install at the command prompt.

    Select run 'npm install' in the context menu of the package.json file in the project root directory.

1.2. Install React in a blank IntelliJ IDEA project

In this case, you will have to configure the build pipeline  yourself as described in Building a React application below . Learn more about how to add React to a project on the React official website .

1" Create an empty IntelliJ IDEA project  

  1》File→New→Project→New Project

  2" Select the Static Web option to create a Static Web

  3" Specify the project name and storage path [note that the name cannot have capital letters]

2" Install React in an empty project

  1> Open a blank project where you will be using React.

  2" Open Terminal ( View | Tool Windows | Terminal) and use: npm install --save react react-dom

3.3. Start with an existing React application

  To continue developing an existing React application, open it in IntelliJ IDEA and download the required dependencies.

1" Open the application source already in the machine

  File→Open

  Or you can also check out the project from the repository

2" download dependencies

  Run on the package, npm install

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325004016&siteId=291194637