React 部署
Netlify
部署前增加路由配置
请确保创建 public/_redirects 具有以下重写规则的文件:
/* /index.html 200
构建项目时,Create React App 会将public文件夹内容放入构建输出中。
常见问题
1. NPM start returns error, "There might be a problem with the project dependency tree" Webpack 版本不同
- create a .env at the root of the folder react folder
- 输入 SKIP_PREFLIGHT_CHECK=true inside of .env file
- now run in 终端 npm start .
2. How to prevent Netlify from treating warnings as errors because process.env.CI = true?
将部署时的 Build command 修改为:
CI=false npm run build
3. TypeError: Cannot assign to read only property 'jsx' of object '#Object'
Change typescript version in package.json
"typescript": "~4.0.5",
Change in tsconfig.json
"jsx": "react"
In the terminal
yarn install
yarn start