File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4141 exit 0
4242 elif [ -f "${{ github.workspace }}/package.json" ]; then
4343 echo "manager=npm" >> $GITHUB_OUTPUT
44- echo "command=ci" >> $GITHUB_OUTPUT
44+ echo "command=ci --legacy-peer-deps " >> $GITHUB_OUTPUT
4545 echo "runner=npx --no-install" >> $GITHUB_OUTPUT
4646 exit 0
4747 else
Original file line number Diff line number Diff line change 11# Next.js GitHub Pages部署修复记录
22
33## 问题
4- GitHub Pages部署失败,显示 "Deploy Next.js site to Pages / build (push) Failing after 21s"。
4+ 1 . GitHub Pages部署失败,显示 "Deploy Next.js site to Pages / build (push) Failing after 21s"。
5+ 2 . npm依赖解析错误:React和ReactDOM版本不兼容。
56
67## 原因分析
781 . Next.js 15.x版本需要特定的静态导出配置
892 . Tailwind CSS配置不完整或不兼容
9103 . GitHub Actions工作流配置不适合新版Next.js
11+ 4 . React 19.0.0与react-dom需要的React 19.1.0版本不兼容
1012
1113## 解决方案
1214
@@ -35,6 +37,7 @@ export default nextConfig;
3537
3638### 2. 更新GitHub Actions工作流配置
3739- 删除不必要的 ` next export ` 命令,因为新版Next.js的` build ` 命令已经包含导出功能
40+ - 在npm命令中添加 ` --legacy-peer-deps ` 参数以处理依赖冲突
3841
3942### 3. 修复Tailwind CSS配置
4043- 更新 postcss.config.mjs 以正确配置Tailwind CSS和autoprefixer
@@ -43,7 +46,12 @@ export default nextConfig;
4346
4447### 4. 修复包依赖
4548- 添加autoprefixer和postcss依赖
46- - 确保依赖版本兼容
49+ - 更新React和ReactDOM版本至兼容版本:
50+ ``` json
51+ "react" : " ^19.1.0" ,
52+ "react-dom" : " ^19.1.0"
53+ ```
54+ - 确保所有依赖版本兼容
4755
4856## 测试
4957推送更改到GitHub仓库后,GitHub Actions应该能够成功构建并部署站点到GitHub Pages。
Original file line number Diff line number Diff line change 3030 "framer-motion" : " ^12.6.2" ,
3131 "lucide-react" : " ^0.484.0" ,
3232 "next" : " 15.2.4" ,
33- "react" : " 19.0 .0" ,
34- "react-dom" : " ^19.0 .0" ,
33+ "react" : " ^ 19.1 .0" ,
34+ "react-dom" : " ^19.1 .0" ,
3535 "react-resizable-panels" : " ^2.1.7" ,
3636 "recharts" : " ^2.15.4" ,
3737 "sharp" : " ^0.33.5" ,
You can’t perform that action at this time.
0 commit comments