错误:/app/node_modules/bcrypt/lib/binding/bcrypt_lib.node:无效的ELF标头

问题描述 投票:0回答:1

我正在尝试将REST API部署到heroku。但是,该应用程序无法正常工作。在应用程序日志中,我得到了此

Process exited with status 1
2019-09-23T01:09:55.744676+00:00 heroku[web.1]: Starting process with command `node server.js`
2019-09-23T01:09:58.446510+00:00 heroku[web.1]: Process exited with status 1
2019-09-23T01:09:58.468276+00:00 heroku[web.1]: State changed from starting to crashed
2019-09-23T01:09:58.370869+00:00 app[web.1]: internal/modules/cjs/loader.js:807
2019-09-23T01:09:58.370888+00:00 app[web.1]: return process.dlopen(module, path.toNamespacedPath(filename));
2019-09-23T01:09:58.370890+00:00 app[web.1]: ^
2019-09-23T01:09:58.370892+00:00 app[web.1]: 
2019-09-23T01:09:58.370894+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
2019-09-23T01:09:58.370896+00:00 app[web.1]: at Object.Module._extensions..node (internal/modules/cjs/loader.js:807:18)
2019-09-23T01:09:58.370898+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:653:32)
2019-09-23T01:09:58.370900+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2019-09-23T01:09:58.370902+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:585:3)
2019-09-23T01:09:58.370904+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:692:17)
2019-09-23T01:09:58.370906+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:25:18)
2019-09-23T01:09:58.370909+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2019-09-23T01:09:58.370910+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:778:30)
2019-09-23T01:09:58.370912+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
2019-09-23T01:09:58.370915+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:653:32)
2019-09-23T01:09:58.370917+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2019-09-23T01:09:58.370919+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:585:3)
2019-09-23T01:09:58.370921+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:692:17)
2019-09-23T01:09:58.370923+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:25:18)
2019-09-23T01:09:58.370924+00:00 app[web.1]: at Object.<anonymous> (/app/routes/auth.js:6:16)
2019-09-23T01:09:58.370926+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:778:30)

这似乎与bcrypt模块有关。我尝试了此处建议的解决方案:https://github.com/kelektiv/node.bcrypt.js/issues/595https://github.com/kelektiv/node.bcrypt.js/issues/635

例如:npm rebuild bcrypt --build-from-source

这里是package.json文件:

{
  "name": "server",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bcrypt": "^3.0.6",
    "body-parser": "^1.18.3",
    "cors": "^2.8.4",
    "cron": "^1.7.2",
    "express": "^4.16.3",
    "jsonwebtoken": "^8.3.0",
    "jwt-simple": "^0.5.6",
    "mapnik": "^4.3.1",
    "mkdirp": "^0.5.1",
    "mongoose": "^5.7.1",
    "multer": "^1.4.1",
    "nodemailer": "^6.3.0",
    "request": "^2.88.0",
    "ug": "0.0.8"
  }
}

这些解决方案都不适合我!我该如何解决这个问题?

node.js heroku bcrypt
1个回答
0
投票

我有同样的问题,但使用Docker。原来node_modules文件夹正在上传。确保将node_modules添加到您的.gitignore(和/或.dockerignore)中

© www.soinside.com 2019 - 2024. All rights reserved.