node.js - Heroku 无法使用 bcrypt 部署 node.js
问题描述
在将 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,但似乎问题出在 node-gyp 上,而不是 node_modules 本身。我建议从bcrypt包切换到bcryptjs。它是用js编写的,性能稍差一些,但它不需要python依赖,这使得构建过程不那么复杂。API 是相同的,因此在您的代码中更改它是微不足道的。这不完全是您问题的答案,但我希望它对您有所帮助。
我会发表评论,而不是发布答案,但我的声誉还不足以做到这一点。
推荐阅读
- android - 在 kotlin 中以编程方式在线性布局中设置图像视图
- python - Django 管理面板滞后并且不显示任何内容
- reactjs - 对象数组类型声明中的打字稿可为空的键
- function - 每当页面以颤振加载时,如何运行函数?
- ieee-754 - IEEE 754浮点除法或减法本身是否总是产生相同的值?
- php - php中的隐蔽条件查询到laravel
- python - 如何使用 PIL 图像对象列表在内存中创建 zip 文件?
- google-cloud-platform - 在请求一直被拒绝的情况下,增加 Google Compute Engine 中 VM 实例的 CPU 配额的方法是什么?
- azure - Azure 逻辑应用:使用 GROUP BY 的查询不支持继续令牌
- angular - 离子单元测试 - 找不到管道“日期”