[英]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.