在 vercel 上部署 next.js 应用程序时出现白屏

问题描述 投票:0回答:1

我在 Vercel 上部署 Next.js 应用程序时遇到白屏问题。我已尝试以下故障排除步骤,但错误仍然存在:

以下是有助于诊断的其他详细信息:

**Package.json file:** {
  "name": "nextjs",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@chakra-ui/icons": "^2.1.1",
    "@chakra-ui/react": "^2.8.2",
    "@emotion/react": "^11.11.3",
    "@emotion/styled": "^11.11.0",
    "framer-motion": "^10.18.0",
    "next": "14.0.4",
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "react-icons": "^5.0.1"
  },
  "devDependencies": {
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "autoprefixer": "^10.0.1",
    "eslint": "^8",
    "eslint-config-next": "14.0.4",
    "postcss": "^8",
    "tailwindcss": "^3.3.0",
    "typescript": "^5"
  }
}

Github 仓库:https://github.com/esvin2661/esvin-portfolio

提前致谢!

更新了 npm 添加了链接到 Vercel Web 域的主页:https://esvin-portfolio.vercel.app/

http next.js console vercel
1个回答
0
投票

除了确保您的构建准确无误之外, 我为部署到 vercel 的人发现的最终解决方案是创建一个单独的新文件;您需要在根目录或 src(源文件夹)下创建一个新文件,并将其命名为 vercel.json[src 文件夹][1]

之后,您可以将此代码上传到其中,该代码实际上的作用是告诉 vercel 将所有页面文件夹重新路由到具有“/”路由符号的 home(无论您如何称呼它)文件夹并渲染以斜线开头的页面。

...

{
"rewrites": [
    {"source": "/(.*)", "destination":"/"}
]
}

...

© www.soinside.com 2019 - 2024. All rights reserved.