Express 应用挂起 git 推送到 Heroku

Express app is hanging on git push to Heroku

我是 运行 一个处理 NextJS 应用程序路由的 Express 应用程序。在代码中,我在最后 运行 listen,这是我将我的应用程序推送到 Heroku 时看到的最后一件事。

为了推送应用程序,我目前正在做的只是提交整个目录并推送到 Heroku master。该应用是未编译的 Next 应用,具有 package.json 和:

"start": "cross-env NODE_ENV=production node server.js"

const express = require('express')
const bodyParser = require('body-parser')
const next = require('next')
const admin = require('firebase-admin')
const port = 3000
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
const config = require('./credentials/client')
const firebase = admin.initializeApp(
  ...
)

app.prepare().then(() => {
  const server = express()

  server.use(bodyParser.json())
  server.use(
    session({
      secret: 'secret',
      saveUninitialized: true,
      store: new FirebaseStore({
        database: firebase.database()
      }),
      resave: false,
      rolling: true,
      httpOnly: true,
      cookie: { maxAge: 604800000 } // week
    })
  )

  server.use((req, res, next) => {
    req.firebaseServer = firebase
    next()
  })

  server.get('*', (req, res) => {
    return handle(req, res)
  })

  server.listen(port, err => {
    if (err) throw err
    console.log(`> Ready on http://localhost:${port}`)
  })
})

产生此结果的任何原因:

remote:        > Ready on http://localhost:3000
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: the remote end hung up unexpectedly
fatal: the remote end hung up unexpectedly
Everything up-to-date

这是由于 package.json 错误造成的!

我的构建脚本也在启动服务器,而不是将 post-build 作为单独的命令启动。