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 build-in functionality. There are hundreds of template with many advanced features are available in npm package server. Create React App allows the users to select the template through –template command line switch.
create-react-app my-app --template typescript
Installing a dependency
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 started 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 secure mode (HTTPS), set an environment variable, HTTPS and set it to true before starting the application. For example, in windows command prompt (cmd.exe), the below command set HTTPS and starts the application is HTTPS mode.
cmd
set HTTPS=true && npm start
npm start and npm run are same further check with below link
https://docs.npmjs.com/cli/v8/commands/npm-run-script
Building
A single command is enough to create a production build of the application.
npm run build
> expense-manager@0.1.0 build path\to\expense-manager
> react-scripts build
Creating an optimized production build...
Compiled with warnings.
File sizes after gzip:
41.69 KB build\static\js\2.a164da11.chunk.js
2.24 KB build\static\js\main.de70a883.chunk.js
1.4 KB build\static\js\3.d8a9fc85.chunk.js
1.17 KB build\static\js\runtime-main.560bee6e.js
493 B build\static\css\main.e75e7bbe.chunk.css
The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.
The build folder is ready to be deployed.
You may serve it with a static server:
npm install -g serve
serve -s build