错误:未能在 heroku 中推送一些参考

Posted

技术标签:

【中文标题】错误:未能在 heroku 中推送一些参考【英文标题】:Error: failed to push some refs in heroku 【发布时间】:2021-03-26 08:59:01 【问题描述】:

我正在学习如何在 Heroku 中进行部署的在线课程。我创建了一个 Git 存储库,并在那里上传并提交了所有文件。然后我输入了这些命令:

    heroku create heroku git:remote -a name_provided_by_heroku git push heroku main

在命令 3 之后,我在 cmd 中遇到了这个错误:

Enumerating objects: 4357, done.
Counting objects: 100% (4357/4357), done.
Delta compression using up to 4 threads
Compressing objects: 100% (4125/4125), done.
Writing objects: 100% (4357/4357), 3.64 MiB | 297.00 KiB/s, done.
Total 4357 (delta 935), reused 3 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
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):  unspecified
remote:        engines.npm (package.json):   unspecified (use default)
remote:
remote:        Resolving node version 12.x...
remote:        Downloading and installing node 12.20.0...
remote:        Using default npm version: 6.14.8
remote:
remote: -----> Installing dependencies
remote:        Prebuild detected (node_modules already exists)
remote:        Rebuilding any native modules
remote:
remote:        > bcrypt@5.0.0 install /tmp/build_88514da7/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@5.0.0 install: `node-pre-gyp install --fallback-to-build`
remote:        npm ERR! Exit status 126
remote:        npm ERR!
remote:        npm ERR! Failed at the bcrypt@5.0.0 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.MO7JR/_logs/2020-12-15T17_16_14_007Z-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://devcenter.heroku.com/articles/node-best-practices#only-git-the-important-bits
remote:
remote:        - Node version not specified in package.json
remote:          https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
remote:
remote:        Love,
remote:        Heroku
remote:
remote:  !     Push rejected, failed to compile Node.js app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to safe-dawn-68695.
remote:
To https://git.heroku.com/safe-dawn-68695.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/safe-dawn-68695.git'

我是 Heroku 的新手,所以我无法理解错误的含义。也尝试使用git push heroku HEAD:master,但遇到了同样的错误。

我该如何解决这个问题?

【问题讨论】:

问题出在你的脚本上你用谷歌搜索了错误信息吗? 是的,我用谷歌搜索了这个错误并找到了一些关于制作新回购的答案,然后按照相同的方法,尝试 'git push heroku HEAD:master' 这对其他人有用,并创建了一个分支然后尝试部署它但出现了同样的错误。没有提到 bcrypt,所以我无法挖掘太多。 因为它在这里失败 > bcrypt@5.0.0 install /tmp/build_88514da7/node_modules/bcrypt remote: > node-pre-gyp install --fallback-to-build remote: remote: sh: 1 : node-pre-gyp: 权限被拒绝 那么解决这个问题的下一步应该是什么?我卸载并重新安装了 bcrypt,但它没有工作 你需要这个模块吗? 【参考方案1】:

参考本文:node-pre-gyp: Permission denied in heroku push

删除根文件夹中的 node_modules 文件夹 rm -rf node_modules 因为 heroku 会安装你所有的依赖项,我希望这能工作

所以删除你的节点模块文件夹并再次执行 1 2 3

【讨论】:

成功了!!非常感谢您为解决此问题所付出的时间和精力。非常感谢。

以上是关于错误:未能在 heroku 中推送一些参考的主要内容,如果未能解决你的问题,请参考以下文章

未能将一些参考资料推送到 git@heroku.com

“未能锁定”错误

Heroku 推送失败

推送到Heroku时Ruby on Rails错误

在 Heroku 上清理 git repo

错误 R10(启动超时)-> Web 进程未能在启动后 60 秒内绑定到 $PORT - HEROKU ERROR