在部署Nodejs应用程序时了解日志中的Heroku bcrypt错误

时间:2017-12-12 18:23:58

标签: node.js heroku mean-stack bcrypt

我正在尝试将我的node.js应用程序部署到Heroku。它在本地运行得非常好,但是当我尝试部署它时,我会继续这样做:

2017-12-12T17:32:18.220591+00:00 app[web.1]: > ev@1.0.0 start /app
2017-12-12T17:32:18.220592+00:00 app[web.1]: > node app.js
2017-12-12T17:32:18.220592+00:00 app[web.1]: 
2017-12-12T17:32:18.898850+00:00 heroku[web.1]: Process exited with status 1
2017-12-12T17:32:18.910740+00:00 heroku[web.1]: State changed from starting to crashed
2017-12-12T17:32:18.819322+00:00 app[web.1]: module.js:664
2017-12-12T17:32:18.819338+00:00 app[web.1]:   return process.dlopen(module, path._makeLong(filename));
2017-12-12T17:32:18.819339+00:00 app[web.1]:                  ^
2017-12-12T17:32:18.819339+00:00 app[web.1]: 
2017-12-12T17:32:18.819340+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
2017-12-12T17:32:18.819341+00:00 app[web.1]:     at Object.Module._extensions..node (module.js:664:18)
2017-12-12T17:32:18.819342+00:00 app[web.1]:     at Module.load (module.js:554:32)
2017-12-12T17:32:18.819342+00:00 app[web.1]:     at tryModuleLoad (module.js:497:12)
2017-12-12T17:32:18.819343+00:00 app[web.1]:     at Function.Module._load (module.js:489:3)
2017-12-12T17:32:18.819343+00:00 app[web.1]:     at Module.require (module.js:579:17)
2017-12-12T17:32:18.819344+00:00 app[web.1]:     at require (internal/module.js:11:18)
2017-12-12T17:32:18.819344+00:00 app[web.1]:     at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2017-12-12T17:32:18.819345+00:00 app[web.1]:     at Module._compile (module.js:635:30)
2017-12-12T17:32:18.819345+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:646:10)
2017-12-12T17:32:18.819345+00:00 app[web.1]:     at Module.load (module.js:554:32)
2017-12-12T17:32:18.819346+00:00 app[web.1]:     at tryModuleLoad (module.js:497:12)
2017-12-12T17:32:18.819346+00:00 app[web.1]:     at Function.Module._load (module.js:489:3)
2017-12-12T17:32:18.819346+00:00 app[web.1]:     at Module.require (module.js:579:17)
2017-12-12T17:32:18.819347+00:00 app[web.1]:     at require (internal/module.js:11:18)
2017-12-12T17:32:18.819347+00:00 app[web.1]:     at Object.<anonymous> (/app/models/users.js:3:14)
2017-12-12T17:32:18.819347+00:00 app[web.1]:     at Module._compile (module.js:635:30)
2017-12-12T17:32:18.827094+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-12-12T17:32:18.827465+00:00 app[web.1]: npm ERR! errno 1
2017-12-12T17:32:18.828807+00:00 app[web.1]: npm ERR! ev@1.0.0 start: `node app.js`
2017-12-12T17:32:18.828992+00:00 app[web.1]: npm ERR! Exit status 1
2017-12-12T17:32:18.829148+00:00 app[web.1]: npm ERR! 
2017-12-12T17:32:18.829260+00:00 app[web.1]: npm ERR! Failed at the ev@1.0.0 start script.
2017-12-12T17:32:18.829357+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2017-12-12T17:32:18.834511+00:00 app[web.1]: 
2017-12-12T17:32:18.834634+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2017-12-12T17:32:18.834782+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2017-12-12T17_32_18_830Z-debug.log 

我已经完成了npm install和npm install bcrypt,但错误仍然存​​在。根据我对日志的理解,我认为很明显错误与bcrypt有关?

这是我的package.json文件:

{
  "name": "ev",
  "version": "1.0.0",
  "description": "search",
  "main": "app.js",
  "scripts": {
    "start": "node app.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "dependencies": {
    "bcrypt": "^1.0.3",
    "body-parser": "*",
    "express": "*",
    "jsonwebtoken": "^8.1.0",
    "mongoose": "*"
  },
  "author": "My Name",
  "license": "ISC"

1 个答案:

答案 0 :(得分:0)

您可以使用纯JS版本的bcrypt库。 像这样的东西

https://github.com/dcodeIO/bcrypt.js

这没有任何本机依赖,应该可以正常工作。 我们在将部署具有本机依赖性的应用程序部署到heroku和其他云平台时遇到了很多困难,我们不得不将一些库(如bcrypt)与纯js版本交换。