我有一个Node.js应用托管在Heroku。每次我做一个git push heroku,我得到以下错误:

Counting objects: 14, done.
Delta compression using up to 6 threads.
Compressing objects: 100% (12/12), done.
Writing objects: 100% (12/12), 1.20 KiB, done.
Total 12 (delta 8), reused 0 (delta 0)

-----> Node.js app detected
-----> Resolving engine versions
       Using Node.js version: 0.6.20
       Using npm version: 1.2.12
-----> Fetching Node.js binaries
-----> Vendoring node into slug
-----> Installing dependencies with npm
       npm http GET https://registry.npmjs.org/pg/0.6.15
       npm http GET https://registry.npmjs.org/socket.io
       npm http 200 https://registry.npmjs.org/pg/0.6.15
       npm http GET https://registry.npmjs.org/pg/-/pg-0.6.15.tgz
       npm http 200 https://registry.npmjs.org/socket.io
       npm http GET https://registry.npmjs.org/socket.io/-/socket.io-0.9.13.tgz
       npm http 200 https://registry.npmjs.org/pg/-/pg-0.6.15.tgz
       npm http 200 https://registry.npmjs.org/socket.io/-/socket.io-0.9.13.tgz
       npm http GET https://registry.npmjs.org/socket.io-client/0.9.11
       npm http GET https://registry.npmjs.org/policyfile/0.0.4
       npm http GET https://registry.npmjs.org/base64id/0.1.0
       npm http GET https://registry.npmjs.org/redis/0.7.3
       npm http GET https://registry.npmjs.org/generic-pool/1.0.9
       npm http 200 https://registry.npmjs.org/policyfile/0.0.4
       npm http GET https://registry.npmjs.org/policyfile/-/policyfile-0.0.4.tgz

       npm http 200 https://registry.npmjs.org/base64id/0.1.0
       npm http GET https://registry.npmjs.org/base64id/-/base64id-0.1.0.tgz
       npm http 200 https://registry.npmjs.org/generic-pool/1.0.9
       npm http GET https://registry.npmjs.org/generic-pool/-/generic-pool-1.0.9
.tgz
       npm http 200 https://registry.npmjs.org/socket.io-client/0.9.11
       npm http GET https://registry.npmjs.org/socket.io-client/-/socket.io-clie
nt-0.9.11.tgz
       npm http 200 https://registry.npmjs.org/redis/0.7.3
       npm http GET https://registry.npmjs.org/redis/-/redis-0.7.3.tgz
       npm http 200 https://registry.npmjs.org/policyfile/-/policyfile-0.0.4.tgz

       npm http 200 https://registry.npmjs.org/base64id/-/base64id-0.1.0.tgz
       npm http 200 https://registry.npmjs.org/generic-pool/-/generic-pool-1.0.9
.tgz
       npm http 200 https://registry.npmjs.org/socket.io-client/-/socket.io-clie
nt-0.9.11.tgz
       npm http 200 https://registry.npmjs.org/redis/-/redis-0.7.3.tgz

       > pg@0.6.15 install /tmp/build_36us8733h7kkr/node_modules/pg
       > node-waf configure build || (exit 0)

       Checking for program g++ or c++          : /usr/bin/g++
       Checking for program cpp                 : /usr/bin/cpp
       Checking for program ar                  : /usr/bin/ar
       Checking for program ranlib              : /usr/bin/ranlib
       Checking for g++                         : ok
       Checking for node path                   : not found
       Checking for node prefix                 : ok /tmp/node-node-nNUw
       Checking for program pg_config           : /usr/bin/pg_config
       'configure' finished successfully (0.058s)
       Waf: Entering directory `/tmp/build_36us8733h7kkr/node_modules/pg/build'
       [1/2] cxx: src/binding.cc -> build/Release/src/binding_1.o
       [2/2] cxx_link: build/Release/src/binding_1.o -> build/Release/binding.no
de
       Waf: Leaving directory `/tmp/build_36us8733h7kkr/node_modules/pg/build'
       'build' finished successfully (0.492s)
       npm http GET https://registry.npmjs.org/uglify-js/1.2.5
       npm http GET https://registry.npmjs.org/ws
       npm http GET https://registry.npmjs.org/xmlhttprequest/1.4.2
       npm http GET https://registry.npmjs.org/active-x-obfuscator/0.0.1
       npm http 200 https://registry.npmjs.org/active-x-obfuscator/0.0.1
       npm http GET https://registry.npmjs.org/active-x-obfuscator/-/active-x-ob
fuscator-0.0.1.tgz
       npm http 200 https://registry.npmjs.org/uglify-js/1.2.5
       npm http GET https://registry.npmjs.org/uglify-js/-/uglify-js-1.2.5.tgz
       npm http 200 https://registry.npmjs.org/xmlhttprequest/1.4.2
       npm http GET https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1
.4.2.tgz
       npm http 200 https://registry.npmjs.org/ws
       npm http GET https://registry.npmjs.org/ws/-/ws-0.4.25.tgz
       npm http 200 https://registry.npmjs.org/active-x-obfuscator/-/active-x-ob
fuscator-0.0.1.tgz
       npm http 200 https://registry.npmjs.org/uglify-js/-/uglify-js-1.2.5.tgz
       npm http 200 https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1
.4.2.tgz
       npm http 200 https://registry.npmjs.org/ws/-/ws-0.4.25.tgz
       npm http GET https://registry.npmjs.org/zeparser/0.0.5
       npm http GET https://registry.npmjs.org/commander
       npm http GET https://registry.npmjs.org/tinycolor
       npm http GET https://registry.npmjs.org/options
       npm http 200 https://registry.npmjs.org/zeparser/0.0.5
       npm http GET https://registry.npmjs.org/zeparser/-/zeparser-0.0.5.tgz
       npm http 200 https://registry.npmjs.org/options
       npm http GET https://registry.npmjs.org/options/-/options-0.0.3.tgz
       npm http 200 https://registry.npmjs.org/tinycolor
       npm http GET https://registry.npmjs.org/tinycolor/-/tinycolor-0.0.1.tgz
       npm http 200 https://registry.npmjs.org/commander
       npm http GET https://registry.npmjs.org/commander/-/commander-0.6.1.tgz
       npm http 200 https://registry.npmjs.org/zeparser/-/zeparser-0.0.5.tgz
       npm http 200 https://registry.npmjs.org/options/-/options-0.0.3.tgz
       npm http 200 https://registry.npmjs.org/tinycolor/-/tinycolor-0.0.1.tgz
       npm http 200 https://registry.npmjs.org/commander/-/commander-0.6.1.tgz

       > ws@0.4.25 install /tmp/build_36us8733h7kkr/node_modules/socket.io/node_
modules/socket.io-client/node_modules/ws
       > (node-gyp rebuild 2> builderror.log) || (exit 0)

       make: Entering directory `/tmp/build_36us8733h7kkr/node_modules/socket.io
/node_modules/socket.io-client/node_modules/ws/build'
         CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
         SOLINK_MODULE(target) Release/obj.target/bufferutil.node
         SOLINK_MODULE(target) Release/obj.target/bufferutil.node: Finished
         COPY Release/bufferutil.node
         CXX(target) Release/obj.target/validation/src/validation.o
         SOLINK_MODULE(target) Release/obj.target/validation.node
         SOLINK_MODULE(target) Release/obj.target/validation.node: Finished
         COPY Release/validation.node
       make: Leaving directory `/tmp/build_36us8733h7kkr/node_modules/socket.io/
node_modules/socket.io-client/node_modules/ws/build'
       npm ERR! cb() never called!
       npm ERR! not ok code undefined
       npm ERR! cb() never called!
       npm ERR! not ok code 1
 !     Failed to install --production dependencies with npm
 !     Heroku push rejected, failed to compile Node.js app

To git@heroku.com:still-chamber-1286.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:still-chamber-1286.git'

错误在最后几行:

npm ERR! cb() never called!
           npm ERR! not ok code undefined
           npm ERR! cb() never called!
           npm ERR! not ok code 1
     !     Failed to install --production dependencies with npm
     !     Heroku push rejected, failed to compile Node.js app

    To git@heroku.com:still-chamber-1286.git
     ! [remote rejected] master -> master (pre-receive hook declined)
    error: failed to push some refs to 'git@heroku.com:still-chamber-1286.git'

我以前把我的代码推送给Heroku没有任何问题;从星期一开始,我才出现这个错误。

我在网上看到过类似的帖子,提到的错误略有不同,但还没有看到一个![远程拒绝]master -> master(预接收钩子拒绝)之前。


当前回答

可能有两种可能性=>

尝试更新你的node js和npm。 权限问题=> a.将您的解决方案移动到您各自用户帐户的c驱动器上 b.以管理员身份运行bash或cmd命令。

希望这能解决你的问题

其他回答

我建议:改用纱线!—Yarn是一个使用相同包的包管理器。Json文件和node_modules文件夹作为npm。

对于npm,我也遇到了同样的问题:在CentOS 6安装中,我得到ERR cb()从未重复调用错误,并且无法找到一种方法让npm可靠地完成某些包的安装(例如webpack)。- Yarn工作完美无缺,即使在脆弱的网络连接上。

迁移到Yarn很容易。大多数子命令是相同的。他们有一个很好的移民指南。阅读最后方便的CLI命令比较。

我在NPM 1.3.11版本中遇到了同样的问题,并通过多次重新运行相同的命令来解决它(在我的例子中是“NPM update -g”)。在随后的每次运行中,不同的包都会弹出错误,最终所有内容都成功更新。

至少对我来说,这似乎是由网络问题引起的(下载损坏)。我还得到了一个关于无效包的错误,我能够通过删除“tmp.tgz”的所有实例来解决。

编辑:(可能无关,但如果这对任何人都有帮助:我使用Windows,并在收到初始错误后以管理员身份启动命令提示符)。

从mdp留下的地方开始,问题出在节点0.10.19和npm 1.3.11上

我发现最简单的方法来管理降级,让事情顺利进行NVM,这里有一个很好的教程如何使用它。我用NVM修改了服务器环境,并在几分钟内将其从0.10.19降级到0.10.18。

我知道这是一个老问题,你们中的许多人已经给出了答案。只是分享我的经验与这个错误,我是如何解决的。

这一切都是在我将我的Node版本升级到> 12之后开始的,我确实经历了所有的答案,并尝试按照步骤清除npm缓存,删除node_modules文件夹。没人能解决我的问题。

在我的案例中,根本原因是代理限制安装。我删除了代理设置来解决这个问题。

检查是否有代理配置 NPM配置列表 删除它们 NPM配置删除代理 NPM删除http代理 NPM删除http -proxy 现在试试 npm安装

对于mac用户(HighSierra),不使用brew安装节点。它会把npm弄乱。我必须卸载node并使用nodejs.org主源代码中的包进行安装:https://nodejs.org/en/

这里有一个不使用brew的简单指南:https://coolestguidesontheplanet.com/installing-node-js-on-macos/