简体   繁体   English

如何在部署 expressjs 应用程序时修复 heroku 错误?

[英]how to fix heroku error while deploying an expressjs app?

I've been trying to fix a heroku api but I keep getting an error which I cant fix.我一直在尝试修复 heroku api 但我不断收到无法修复的错误。 The app is not even running, it goes straight to the error.该应用程序甚至没有运行,它直接进入错误。 It was working until I recently made an update to the api.它一直有效,直到我最近对 api 进行了更新。 The error is shown as错误显示为

    2019-10-18T21:40:06.936984+00:00 app[web.1]: at Function.Module._load 
    (internal/modules/cjs/loader.js:585:3)
    2019-10-18T21:40:06.936986+00:00 app[web.1]: at Module.require 
    (internal/modules/cjs/loader.js:692:17)
     2019-10-18T21:40:06.936988+00:00 app[web.1]: at require 
     (internal/modules/cjs/helpers.js:25:18)
    2019-10-18T21:40:06.936989+00:00 app[web.1]: at Object.<anonymous> (/app/routes/api.js:7:16)
    2019-10-18T21:40:06.936991+00:00 app[web.1]: at Module._compile 
    (internal/modules/cjs/loader.js:778:30)
    2019-10-18T21:40:06.944691+00:00 app[web.1]: npm ERR! code ELIFECYCLE

    2019-10-18T21:40:06.945081+00:00 app[web.1]: npm ERR! errno 1
    2019-10-18T21:40:06.946204+00:00 app[web.1]: npm ERR! quickJobs-api@1.0.0 start: `node 
    server.js`
2019-10-18T21:40:06.946319+00:00 app[web.1]: npm ERR! Exit status 1
2019-10-18T21:40:06.946542+00:00 app[web.1]: npm ERR!
2019-10-18T21:40:06.946663+00:00 app[web.1]: npm ERR! Failed at the quickJobs-api@1.0.0 start script.
2019-10-18T21:40:06.946779+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-10-18T21:40:06.953214+00:00 app[web.1]:
2019-10-18T21:40:06.953367+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-10-18T21:40:06.953452+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-10-18T21_40_06_948Z-debug.log
2019-10-18T21:40:07.008783+00:00 heroku[web.1]: Process exited with status 1
2019-10-18T21:40:24.571093+00:00 heroku[web.1]: State changed from crashed to starting
2019-10-18T22:05:16.977483+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=quickjobsapi.herokuapp.com request_id=a50a5c3e-7152-4ce1-942f-df572188531b fwd="63.143.196.162" dyno= connect= serv
ice= status=503 bytes= protocol=https
2019-10-18T22:05:17.639126+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=quickjobsapi.herokuapp.com request_id=405f9fd7-ae38-478e-b182-7e5306ab0fa6 fwd="63.143.196.162" dyno= co
nnect= service= status=503 bytes= protocol=https
2019-10-18T22:05:48.086732+00:00 heroku[web.1]: State changed from crashed to starting
2019-10-18T22:05:50.688489+00:00 heroku[web.1]: Starting process with command `npm start`
2019-10-18T22:05:53.119843+00:00 app[web.1]:
2019-10-18T22:05:53.119869+00:00 app[web.1]: > quickJobs-api@1.0.0 start /app
2019-10-18T22:05:53.119871+00:00 app[web.1]: > node server.js
2019-10-18T22:05:53.119872+00:00 app[web.1]:
2019-10-18T22:05:54.001916+00:00 heroku[web.1]: State changed from starting to crashed
2019-10-18T22:05:53.873724+00:00 app[web.1]: internal/modules/cjs/loader.js:807
2019-10-18T22:05:53.873754+00:00 app[web.1]: return process.dlopen(module, path.toNamespacedPath(filename));
2019-10-18T22:05:53.873756+00:00 app[web.1]: ^
2019-10-18T22:05:53.873758+00:00 app[web.1]:
2019-10-18T22:05:53.873760+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
2019-10-18T22:05:53.873761+00:00 app[web.1]: at Object.Module._extensions..node (internal/modules/cjs/loader.js:807:18)
2019-10-18T22:05:53.873763+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:653:32)
2019-10-18T22:05:53.873765+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2019-10-18T22:05:53.873767+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:585:3)
2019-10-18T22:05:53.873768+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:692:17)
2019-10-18T22:05:53.873770+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:25:18)
2019-10-18T22:05:53.873771+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2019-10-18T22:05:53.873773+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:778:30)
2019-10-18T22:05:53.882321+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-10-18T22:05:53.882732+00:00 app[web.1]: npm ERR! errno 1
2019-10-18T22:05:53.883970+00:00 app[web.1]: npm ERR! quickJobs-api@1.0.0 start: `node server.js`
2019-10-18T22:05:53.884082+00:00 app[web.1]: npm ERR! Exit status 1
2019-10-18T22:05:53.884277+00:00 app[web.1]: npm ERR!
2019-10-18T22:05:53.884398+00:00 app[web.1]: npm ERR! Failed at the quickJobs-api@1.0.0 start script.
2019-10-18T22:05:53.884514+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-10-18T22:05:53.914312+00:00 app[web.1]:
2019-10-18T22:05:53.914489+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-10-18T22:05:53.914584+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-10-18T22_05_53_885Z-debug.log
2019-10-18T22:05:54.019964+00:00 heroku[web.1]: State changed from crashed to starting
2019-10-18T22:05:53.977749+00:00 heroku[web.1]: Process exited with status 1
2019-10-18T22:05:57.322980+00:00 heroku[web.1]: Starting process with command `npm start`
2019-10-18T22:06:00.008642+00:00 app[web.1]:
2019-10-18T22:06:00.008674+00:00 app[web.1]: > quickJobs-api@1.0.0 start /app

2019-10-18T22:06:00.008676+00:00 app[web.1]: > node server.js
2019-10-18T22:06:00.008678+00:00 app[web.1]:
2019-10-18T22:06:00.907169+00:00 app[web.1]: internal/modules/cjs/loader.js:807
2019-10-18T22:06:00.907208+00:00 app[web.1]: return process.dlopen(module, path.toNamespacedPath(filename));
2019-10-18T22:06:00.907211+00:00 app[web.1]: ^
2019-10-18T22:06:00.907214+00:00 app[web.1]:
2019-10-18T22:06:00.907216+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
2019-10-18T22:06:00.907218+00:00 app[web.1]: at Object.Module._extensions..node (internal/modules/cjs/loader.js:807:18)
2019-10-18T22:06:00.907220+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:653:32)
2019-10-18T22:06:00.907223+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2019-10-18T22:06:00.907225+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:585:3)
2019-10-18T22:06:00.907228+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:692:17)
2019-10-18T22:06:00.907229+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:25:18)
2019-10-18T22:06:00.907232+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2019-10-18T22:06:00.907234+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:778:30)
2019-10-18T22:06:00.907235+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
2019-10-18T22:06:00.907238+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:653:32)
2019-10-18T22:06:00.907242+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2019-10-18T22:06:00.907244+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:585:3)
2019-10-18T22:06:00.907247+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:692:17)
2019-10-18T22:06:00.907249+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:25:18)
2019-10-18T22:06:00.907251+00:00 app[web.1]: at Object.<anonymous> (/app/routes/api.js:7:16)
2019-10-18T22:06:00.907253+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:778:30)
2019-10-18T22:06:00.925298+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-10-18T22:06:00.925759+00:00 app[web.1]: npm ERR! errno 1
2019-10-18T22:06:00.926956+00:00 app[web.1]: npm ERR! quickJobs-api@1.0.0 start: `node server.js`
2019-10-18T22:06:00.927125+00:00 app[web.1]: npm ERR! Exit status 1
2019-10-18T22:06:00.927387+00:00 app[web.1]: npm ERR!
2019-10-18T22:06:00.927644+00:00 app[web.1]: npm ERR! Failed at the quickJobs-api@1.0.0 start script.
2019-10-18T22:06:00.927832+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-10-18T22:06:00.942491+00:00 app[web.1]:
2019-10-18T22:06:00.942496+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-10-18T22:06:00.942498+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-10-18T22_06_00_929Z-debug.log
2019-10-18T22:06:01.013650+00:00 heroku[web.1]: State changed from starting to crashed
2019-10-18T22:06:00.991627+00:00 heroku[web.1]: Process exited with status 1
Git
2019-10-18T22:06:00.778487+00:00 heroku[web.1]: State changed from starting to up
2019-10-18T22:06:01.574620+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=quickjobsapi.herokuapp.com request_id=e500ac9e-cc2f-4cde-9f91-8424f36c57f2 fwd="63.143.196.162" dyno= connect= serv
ice= status=503 bytes= protocol=https
2019-10-18T22:06:02.282334+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=quickjobsapi.herokuapp.com request_id=38013505-dfbc-4e8a-90e4-e55077f9b467 fwd="63.143.196.162" dyno= co
nnect= service= status=503 bytes= protocol=https

My server.js file has我的 server.js 文件有

const express = require('express')
const bodyParser = require('body-parser')
const cors = require('cors')
const app = express()
app.use(cors())
//const PORT = process.env.PORT || 3000;
app.listen(process.env.PORT || 3000,function(){
 console.log('server has been started')
})

app.use(bodyParser.json({limit: "500mb"}));
app.use(bodyParser.urlencoded({limit: "500mb", extended: true, parameterLimit:50000}));
app.use('/api',require('./routes/api'))

The other files are just the api and the schema for mongodb.其他文件只是 api 和 mongodb 的架构。 Please help请帮忙

I see that there is a bcrypt related error.我看到有一个 bcrypt 相关的错误。 Are you using different Node.js version on your local dev and your prod?您是否在本地开发人员和产品上使用不同的 Node.js 版本? If yes then try to ignore the package manager lock file yarn.lock or package-lock.json .如果是,则尝试忽略 package 管理器锁定文件yarn.lockpackage-lock.json

lock file usually "hold" version specific dependency, in some case package with native dependency like bcrypt can cause some issue.锁定文件通常“保留”特定于版本的依赖项,在某些情况下 package 具有像 bcrypt 这样的本机依赖项可能会导致一些问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM