reactjs - 部署 Next.js 项目到 Heroku 失败

标签 reactjs heroku next.js

我正在尝试在heroku 上部署我的next.js 项目,但在应用程序运行时,它失败了,这是失败的日志。

2019-11-17T18:23:33.067077+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pens-nextjs.herokuapp.com request_id=f01abc4b-bf9b-4f2e-8b8e-06184580bfc8 fwd="41.232.85.202" dyno= connect= service= status=503 bytes= protocol=https
2019-11-17T18:23:37.203987+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pens-nextjs.herokuapp.com request_id=f4f94391-c79c-4503-9751-fe8a6c5461d3 fwd="41.232.85.202" dyno= connect= service= status=503 bytes= protocol=https
2019-11-17T18:23:38.045712+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pens-nextjs.herokuapp.com request_id=98cc2b80-5631-4af1-9889-26abecca6aec fwd="41.232.85.202" dyno= connect= service= status=503 bytes= protocol=https

最佳答案

我也遇到了同样的问题。 我在 NextJs 应用程序的公共(public)文件夹中添加了 favicon.ico。另外,在 package.json 中添加以下行

"scripts": {
  "dev": "next",
  "build": "next build",
  "start": "next start -p $PORT",
  "heroku-postbuild": "npm run build",
  "test": "echo \"Error: no test specified\" && exit 1"
},

希望这对您有用!

关于reactjs - 部署 Next.js 项目到 Heroku 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58903783/

相关文章:

reactjs - 在 Next.js 上使用 jest 找不到模块错误

javascript - 我如何将交替颜色传递给具有 Array.map 函数的组件?

reactjs - 从react-router-dom url中删除哈希

ruby - Rbenv 和两个版本的 Heroku 客户端

meteor - 未捕获的类型错误 : fs. readFileSync 不是函数

linux - Heroku 上的 Electron 应用程序和与 libpng12.so.0 相关的错误 :

git - 从 CircleCI 推送到 Heroku 时出现协议(protocol)错误

javascript - 在 Next.js 中导入 react-hook-mousetrap 时出现 "Cannot use import statement outside a module"错误

next.js - 即使我在将 Next.js 网站与 ChatGPT 链接时收到响应,为什么还是收到 401 错误?

javascript - 用户路由器();在getServerSideProps :next js里面