gukbi

React

Create Project

JavaScript

npx create-react-app react01

TypeScript

npx create-react-app react01 --template typescript

npx Error on Windows

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
# Then type Y and Enter

npx Error on macos

npx create-react-app react01
npm error code EACCES
npm error syscall open
npm error path /Users/tayaki71751/.npm/_cacache/tmp/2ca2ba2d
npm error errno EACCES
npm error
npm error Your cache folder contains root-owned files, due to a bug in
npm error previous versions of npm which has since been addressed.
npm error
npm error To permanently fix this problem, please run:
npm error   sudo chown -R 501:20 "/Users/tayaki71751/.npm"
npm error Log files were not written due to an error writing to the directory: /Users/tayaki71751/.npm/_logs
npm error You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
# Run
sudo chown -R 501:20 "$HOME/.npm"

eslint

npx eslint --init

Example 1

Add homepage to package.json

Add deploy workflow

on: push: branches: [ “main” ] pull_request: branches: [ “main” ]

jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Build and Deploy React app to GitHub Pages uses: omkartapale/react-deployment-gh-pages@v1.0.0 env: CI: false ```