应用未部署到heroku

时间:2018-06-16 15:31:57

标签: json node.js heroku deployment

我在heroku上部署我的应用时出现问题。我被困住了,找不到答案。我已经完成了heroku故障排除和部署过程。我已经尝试了3天。我已经多次重写我的env文件,每次都这样做,它在localhost上不起作用。我有MONGOD和NODEMON在运行。我恢复原状,它正在工作。但仍然不会在heroku上部署。提前谢谢。

这是我的env.js的样子

module.exports = {
  db: process.env.MONGODB_URI || 'mongodb://localhost/sailcast',
  port: process.env.PORT || 3000
}

package.json

    "scripts": {
    "start": "node index.js",
    "postinstall": "gulp default"
  },
    "dependencies": {
    "bcrypt": "^2.0.1",
    "bluebird": "^3.5.1",
    "body-parser": "^1.18.3",
    "ejs": "^2.6.1",
    "express": "^4.16.3",
    "express-ejs-layouts": "^2.4.0",
    "express-flash": "0.0.2",
    "express-session": "^1.15.6",
    "express-sessions": "^1.0.6",
    "express-static": "^1.2.5",
    "forever": "^0.15.3",
    "method-override": "^2.3.10",
    "mongoose": "^5.1.5",
    "morgan": "^1.9.0",
    "nodemon": "^1.17.5",
    "passport": "^0.4.0",
    "request": "^2.87.0",
    "request-promise": "^4.2.2",
    "yarn": "^1.7.0",
    "yarn.lock": "0.0.1-security"
  },

    "devDependencies": {
    "babel-preset-es2015": "^6.24.1",
    "gulp": "^3.9.1",
    "gulp-babel": "^7.0.1",
    "gulp-clean-css": "^3.9.4",
    "gulp-plumber": "^1.2.0",
    "gulp-sass": "^4.0.1",
    "gulp-uglify": "^3.0.0"
  }

这是heroku日志。我无法弄清楚错误。只是不断收到应用程序错误

    2018-06-16T02:00:26.831441+00:00 app[web.1]: npm ERR! sailcast@1.0.0       
    start: `node index.js`
    2018-06-16T02:00:26.831595+00:00 app[web.1]: npm ERR! Exit status 1
    2018-06-16T02:00:26.831982+00:00 app[web.1]: npm ERR! Failed at the 
    sailcast@1.0.0 start script.
    2018-06-16T02:00:26.831821+00:00 app[web.1]: npm ERR!
    2018-06-16T02:00:26.832134+00:00 app[web.1]: npm ERR! This is probably 
    not a problem with npm. There is likely additional logging output above.
    2018-06-16T02:00:26.839530+00:00 app[web.1]: 
    2018-06-16T02:00:26.839805+00:00 app[web.1]: npm ERR! A complete log of 
    this run can be found in:
    2018-06-16T02:00:26.839898+00:00 app[web.1]: npm ERR!     
    /app/.npm/_logs/2018-06-16T02_00_26_833Z-debug.log
    2018-06-16T02:00:26.898270+00:00 heroku[web.1]: Process exited with 
    status 1
    2018-06-16T02:00:27.233835+00:00 heroku[web.1]: State changed from 
    starting to crashed
    2018-06-16T05:23:18.892587+00:00 heroku[web.1]: State changed from 
    crashed to starting
    2018-06-16T05:23:22.696724+00:00 heroku[web.1]: Starting process with 
    command `npm start`
    2018-06-16T05:23:24.791728+00:00 app[web.1]: 
    2018-06-16T05:23:24.791759+00:00 app[web.1]: > sailcast@1.0.0 start /app
    2018-06-16T05:23:24.791761+00:00 app[web.1]: > node index.js
    2018-06-16T05:23:24.791762+00:00 app[web.1]: 
    2018-06-16T05:23:25.449215+00:00 app[web.1]: module.js:681
    2018-06-16T05:23:25.449238+00:00 app[web.1]: return 
    process.dlopen(module, path._makeLong(filename));
    2018-06-16T05:23:25.449240+00:00 app[web.1]: ^
    2018-06-16T05:23:25.449242+00:00 app[web.1]: 
    2018-06-16T05:23:25.449244+00:00 app[web.1]: Error: 
    /app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
    2018-06-16T05:23:25.449247+00:00 app[web.1]: at Module.load 
    (module.js:565:32)
    2018-06-16T05:23:25.449245+00:00 app[web.1]: at 
    Object.Module._extensions..node (module.js:681:18)
    2018-06-16T05:23:25.449249+00:00 app[web.1]: at tryModuleLoad 
    (module.js:505:12)
    2018-06-16T05:23:25.449250+00:00 app[web.1]: at Function.Module._load 
    (module.js:497:3)
    2018-06-16T05:23:25.449252+00:00 app[web.1]: at Module.require 
    (module.js:596:17)
    2018-06-16T05:23:25.449253+00:00 app[web.1]: at require 
    (internal/module.js:11:18)
    2018-06-16T05:23:25.449255+00:00 app[web.1]: at Object.<anonymous> 
    (/app/node_modules/bcrypt/bcrypt.js:6:16)
    2018-06-16T05:23:25.449257+00:00 app[web.1]: at Module._compile 
    (module.js:652:30)
    2018-06-16T05:23:25.449258+00:00 app[web.1]: at 
    Object.Module._extensions..js (module.js:663:10)
    2018-06-16T05:23:25.449260+00:00 app[web.1]: at Module.load 
    (module.js:565:32)
    2018-06-16T05:23:25.449261+00:00 app[web.1]: at tryModuleLoad 
    (module.js:505:12)
    2018-06-16T05:23:25.449263+00:00 app[web.1]: at Function.Module._load 
    (module.js:497:3)
    2018-06-16T05:23:25.449264+00:00 app[web.1]: at Module.require 
    (module.js:596:17)
    2018-06-16T05:23:25.449266+00:00 app[web.1]: at require 
    (internal/module.js:11:18)
    2018-06-16T05:23:25.449267+00:00 app[web.1]: at Object.<anonymous> 
    (/app/models/user.js:2:16)
    2018-06-16T05:23:25.449269+00:00 app[web.1]: at Module._compile 
    (module.js:652:30)
    2018-06-16T05:23:25.449270+00:00 app[web.1]: at 
    Object.Module._extensions..js (module.js:663:10)
    2018-06-16T05:23:25.449271+00:00 app[web.1]: at Module.load 
    (module.js:565:32)
    2018-06-16T05:23:25.449273+00:00 app[web.1]: at tryModuleLoad 
    (module.js:505:12)
    2018-06-16T05:23:25.449274+00:00 app[web.1]: at Function.Module._load 
    (module.js:497:3)
    2018-06-16T05:23:25.449276+00:00 app[web.1]: at Module.require 
    (module.js:596:17)
    2018-06-16T05:23:25.449277+00:00 app[web.1]: at require 
    (internal/module.js:11:18)
    2018-06-16T05:23:25.457003+00:00 app[web.1]: npm ERR! code ELIFECYCLE
    2018-06-16T05:23:25.457360+00:00 app[web.1]: npm ERR! errno 1
    2018-06-16T05:23:25.458445+00:00 app[web.1]: npm ERR! sailcast@1.0.0 
    start: `node index.js`
    2018-06-16T05:23:25.458586+00:00 app[web.1]: npm ERR! Exit status 1
    2018-06-16T05:23:25.458827+00:00 app[web.1]: npm ERR!
    2018-06-16T05:23:25.458989+00:00 app[web.1]: npm ERR! Failed at the 
    sailcast@1.0.0 start script.
    2018-06-16T05:23:25.459138+00:00 app[web.1]: npm ERR! This is probably 
    not a problem with npm. There is likely additional logging output above.
    2018-06-16T05:23:25.493154+00:00 app[web.1]: 
    2018-06-16T05:23:25.493346+00:00 app[web.1]: npm ERR! A complete log of 
    this run can be found in:
    2018-06-16T05:23:25.493475+00:00 app[web.1]: npm ERR!     
   /app/.npm/_logs/2018-06-16T05_23_25_460Z-debug.log
    2018-06-16T05:23:25.564550+00:00 heroku[web.1]: Process exited with 
    status 1
    2018-06-16T05:23:25.653739+00:00 heroku[web.1]: State changed from 
    starting to crashed
    2018-06-16T10:54:29.552763+00:00 heroku[web.1]: State changed from 
    crashed to starting
    2018-06-16T10:54:35.778827+00:00 heroku[web.1]: Starting process with 
    command `npm start`
    2018-06-16T10:54:39.194359+00:00 app[web.1]: 
    2018-06-16T10:54:39.194379+00:00 app[web.1]: > sailcast@1.0.0 start /app
    2018-06-16T10:54:39.194381+00:00 app[web.1]: > node index.js
    2018-06-16T10:54:39.194383+00:00 app[web.1]: 
    2018-06-16T10:54:40.337060+00:00 app[web.1]: return 
    process.dlopen(module, path._makeLong(filename));
    2018-06-16T10:54:40.337027+00:00 app[web.1]: module.js:681
    2018-06-16T10:54:40.337063+00:00 app[web.1]: ^
    2018-06-16T10:54:40.337065+00:00 app[web.1]: 
    2018-06-16T10:54:40.337067+00:00 app[web.1]: Error: 
    /app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
    2018-06-16T10:54:40.337069+00:00 app[web.1]: at 
    Object.Module._extensions..node (module.js:681:18)
    2018-06-16T10:54:40.337071+00:00 app[web.1]: at Module.load 
    (module.js:565:32)
    2018-06-16T10:54:40.337073+00:00 app[web.1]: at tryModuleLoad 
    (module.js:505:12)
    2018-06-16T10:54:40.337074+00:00 app[web.1]: at Function.Module._load 
    (module.js:497:3)
    2018-06-16T10:54:40.337077+00:00 app[web.1]: at require 
    (internal/module.js:11:18)
    2018-06-16T10:54:40.337076+00:00 app[web.1]: at Module.require 
    (module.js:596:17)
    2018-06-16T10:54:40.337079+00:00 app[web.1]: at Object.<anonymous> 
    (/app/node_modules/bcrypt/bcrypt.js:6:16)
    2018-06-16T10:54:40.337080+00:00 app[web.1]: at Module._compile 
    (module.js:652:30)
    2018-06-16T10:54:40.337082+00:00 app[web.1]: at 
    Object.Module._extensions..js (module.js:663:10)
    2018-06-16T10:54:40.337084+00:00 app[web.1]: at Module.load 
    (module.js:565:32)
    2018-06-16T10:54:40.337087+00:00 app[web.1]: at Function.Module._load 
    (module.js:497:3)
    2018-06-16T10:54:40.337085+00:00 app[web.1]: at tryModuleLoad 
    (module.js:505:12)
    2018-06-16T10:54:40.337088+00:00 app[web.1]: at Module.require 
    (module.js:596:17)
    2018-06-16T10:54:40.337090+00:00 app[web.1]: at require 
    (internal/module.js:11:18)
    2018-06-16T10:54:40.337091+00:00 app[web.1]: at Object.<anonymous> 
    (/app/models/user.js:2:16)
    2018-06-16T10:54:40.337093+00:00 app[web.1]: at Module._compile 
    (module.js:652:30)
    2018-06-16T10:54:40.337094+00:00 app[web.1]: at 
    Object.Module._extensions..js (module.js:663:10)
    2018-06-16T10:54:40.337096+00:00 app[web.1]: at Module.load 
    (module.js:565:32)
    2018-06-16T10:54:40.337097+00:00 app[web.1]: at tryModuleLoad 
    (module.js:505:12)
    2018-06-16T10:54:40.337099+00:00 app[web.1]: at Function.Module._load 
    (module.js:497:3)
    2018-06-16T10:54:40.337100+00:00 app[web.1]: at Module.require 
    (module.js:596:17)
    2018-06-16T10:54:40.337102+00:00 app[web.1]: at require 
    (internal/module.js:11:18)
    2018-06-16T10:54:40.348452+00:00 app[web.1]: npm ERR! code 
    ELIFECYCLE
    2018-06-16T10:54:40.350021+00:00 app[web.1]: npm ERR! errno 1
    2018-06-16T10:54:40.355451+00:00 app[web.1]: npm ERR! sailcast@1.0.0 
    start: `node index.js`
    2018-06-16T10:54:40.356150+00:00 app[web.1]: npm ERR! Exit status 1
    2018-06-16T10:54:40.357519+00:00 app[web.1]: npm ERR!
    2018-06-16T10:54:40.358261+00:00 app[web.1]: npm ERR! Failed at the 
    sailcast@1.0.0 start script.
    2018-06-16T10:54:40.359222+00:00 app[web.1]: npm ERR! This is probably 
    not a problem with npm. There is likely additional logging output above.
    2018-06-16T10:54:40.384205+00:00 app[web.1]: 
    2018-06-16T10:54:40.384792+00:00 app[web.1]: npm ERR! A complete log of 
    this run can be found in:
    2018-06-16T10:54:40.385145+00:00 app[web.1]: npm ERR!     
    /app/.npm/_logs/2018-06-16T10_54_40_366Z-debug.log
    2018-06-16T10:54:40.480586+00:00 heroku[web.1]: State changed from 
    starting to crashed
    2018-06-16T10:54:40.461008+00:00 heroku[web.1]: Process exited with 
    status 1   

1 个答案:

答案 0 :(得分:0)

看起来不错。我想到的一件事是,如果您的文件名为app.js或index.js,因为它是npm start的错误?也许你打错了。

我想到的另一件事是,如果您从heroku设置环境数据库值。既然,我看不到您的整个heroku日志,那是另一种可能性