【问题标题】:Heroku fails in deploying node.js with bcryptHeroku 无法使用 bcrypt 部署 node.js
【发布时间】:2020-06-14 03:16:35
【问题描述】:

将 bookshelf-secure-password 添加到我的服务器后,heroku 无法部署我的服务器,它一直说无法安装 bcrypt。

NPM_CONFIG_DISTURL=https://nodejs.org/download/release/
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:        NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  12.14.0
remote:        engines.npm (package.json):   6.13.4
remote:
remote:        Resolving node version 12.14.0...
remote:        Downloading and installing node 12.14.0...
remote:        npm 6.13.4 already installed with node
remote:
remote: -----> Installing dependencies
remote:        Prebuild detected (node_modules already exists)
remote:        Rebuilding any native modules
remote:
remote:        > bcrypt@3.0.8 install /tmp/build_a26ccc13212d9e4abd4c4c76594f5696/node_modules/bcrypt
remote:        > node-pre-gyp install --fallback-to-build
remote:
remote:        sh: 1: node-pre-gyp: Permission denied
remote:        npm ERR! code ELIFECYCLE
remote:        npm ERR! errno 126
remote:        npm ERR! bcrypt@3.0.8 install: `node-pre-gyp install --fallback-to-build`
remote:        npm ERR! Exit status 126
remote:        npm ERR!
remote:        npm ERR! Failed at the bcrypt@3.0.8 install script.
remote:        npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote:        npm ERR! A complete log of this run can be found in:
remote:        npm ERR!     /tmp/npmcache.aPY9Y/_logs/2020-03-01T18_03_19_337Z-debug.log
remote:
remote: -----> Build failed
remote:
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote:        Some possible problems:
remote:
remote:        - node_modules checked into source control
remote:          https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits

我尝试关注 heroku Troubleshooting Node.js Deploys site https://devcenter.heroku.com/articles/troubleshooting-node-deploys 但没有帮助,我尝试安装 bcrypt,卸载它并安装 bcryptjs 但没有帮助,我不知道现在该怎么办,谁能帮忙?

【问题讨论】:

  • 不要推送你的 node_modules,让 Heroku 为你在 dyno 中安装它们。
  • 我已将 node_modules 添加到 .gitignore 文件中,但没有帮助
  • 您是否实际上已将其从您正在推送的提交中删除?否则你只会忽略它未来的变化。
  • 好的,我该怎么做?
  • 您阅读了吗?例如。 stackoverflow.com/questions/44168609/…

标签: node.js heroku bcrypt bookshelf.js


【解决方案1】:

尽管不应该像 cmets 中提到的那样推送 node_modules,但问题似乎在于 node-gyp,而不是 node_modules 本身。 我建议从 bcrypt 包切换到 bcryptjs。它是用js编写的,性能稍差一些,但它不需要python依赖,这使得构建过程不那么复杂。 API 是相同的,因此在您的代码中更改它是微不足道的。这并不完全是您问题的答案,但我希望它对您有所帮助。

我会发表评论而不是发布答案,但我的声誉还不够高,无法做到这一点。

【讨论】:

  • 您已经提到尝试使用 bcryptjs,但是您推送到存储库的 node_modules 可能仍然包含 bcrypt 包,并且它以某种方式影响了构建过程,即使它没有在 package.json 中指定。
  • 我确实尝试过,正如我的帖子末尾提到的那样,它没有用,但删除 node_ 模块有效
猜你喜欢
  • 2021-08-29
  • 2019-02-16
  • 2017-12-05
  • 1970-01-01
  • 2012-10-30
  • 2018-04-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多