简体   繁体   中英

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. The app is not even running, it goes straight to the error. It was working until I recently made an update to the 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

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. Please help

I see that there is a bcrypt related error. Are you using different Node.js version on your local dev and your prod? If yes then try to ignore the package manager lock file yarn.lock or package-lock.json .

lock file usually "hold" version specific dependency, in some case package with native dependency like bcrypt can cause some issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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