[英]Deploying create-react-app --template-typescript to gh pages
我在部署 typescript react 应用程序时遇到问题,我得到的只是 MainTemplate.tsx 文件中最外部的元素,我应该看到一个日志记录屏幕,我没有本地可用的路由。 另外,我现在已经多次执行 npm run build ,并且说我上次部署是 14 小时前,我该如何刷新它? 我试图将我的 deply 脚本更改为这个,但没有用:
“部署”:“./node_modules/gh-pages/bin/gh-pages-clean.js && gh-pages -d build”
这是我的 package.json
{
"homepage": "https://dziekonskik.github.io/project-money-front",
"name": "project-money-front",
"version": "0.1.0",
"private": false,
"proxy": "http://localhost:3000",
"dependencies": {
"@aws-amplify/ui-react": "^1.2.3",
"@reduxjs/toolkit": "^1.5.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"@types/jest": "^24.9.1",
"@types/node": "^12.20.14",
"@types/react": "^16.14.8",
"@types/react-dom": "^16.9.13",
"@types/react-redux": "^7.1.16",
"@types/styled-components": "^5.1.9",
"aws-amplify": "^4.1.1",
"axios": "^0.21.1",
"dotenv": "^8.2.0",
"formik": "^2.2.9",
"gsap": "^3.7.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^7.2.4",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"styled-components": "^5.3.0",
"styled-reset": "^4.3.4",
"typescript": "~4.1.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "./node_modules/gh-pages/bin/gh-pages-clean.js && gh-pages -d build"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@types/react-router-dom": "^5.1.7",
"gh-pages": "^3.2.3"
}
}
谢谢!
谢谢@yume_chan 将 BrowserRouter 组件更改为 HashRouter 完成了这项工作。 当我改回时也不需要修改部署脚本
"deploy": "gh-pages -d build"
与 HashRouter 一起工作
问候!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.