我是个新手,今天部署了我的第一个网站。但是,只显示了背景图像:https://sabago.github.io/sabago-portfolio/
我的回购:https://github.com/sabago/sabago-portfolio
在谷歌上搜索时,我发现:After uploading a react app to gh-pages, only the background is showing up.,但这不是我真正的问题。
在localhost上一切都运行得很好。
任何帮助都是非常感谢的。
注意:我应该补充说,我在控制台中看到一个错误。我不确定它是否相关,但它指向我在tsconfig (esnext)中的编译器模块。
main.9af833d9.chunk.js:1 Uncaught ReferenceError: exports is not defined
at Module.21 (main.9af833d9.chunk.js:1)
at a ((index):1)
at Object.12 (App.tsx:4)
at a ((index):1)
at Module.44 (main.9af833d9.chunk.js:1)
at a ((index):1)
at Object.14 (main.9af833d9.chunk.js:1)
at a ((index):1)
at t ((index):1)
at Array.r [as push] ((index):1)我的tsconfig
"compilerOptions": {
"target": "es6",
"module": "esnext",
"sourceMap": true,
"jsx": "react",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true
},
"include": [
"src"
]
}package.JSON
{
"homepage": "https://sabago.github.io/sabago-portfolio/",
"name": "sabago",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@types/jest": "^25.2.1",
"@types/node": "^13.13.5",
"@types/react": "^16.9.34",
"@types/react-burger-menu": "^2.6.1",
"@types/react-dom": "^16.9.7",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1",
"typescript": "^3.8.3",
"webpack-cli": "^3.3.11"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages master -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": {
"gh-pages": "^2.2.0",
"webpack-cli": "^3.3.11"
}
}发布于 2020-05-10 08:36:15
您已经安装了gh-pages包,因此要部署您的应用程序,您只需从应用程序目录中的命令行运行以下命令:
yarn deploy这会将你的build目录推送到github页面。如果你还没有构建你的应用程序,你需要首先构建它:
yarn build && yarn deploy发布于 2020-05-10 21:02:25
我不确定这个问题的实际解决方案是什么。我通过从头开始修复了它,但这一次我是在创建react应用程序之后,在编码之前部署的。
https://stackoverflow.com/questions/61705616
复制相似问题