首页 文章

npm ERR cb()从未调用过

提问于
浏览
164

我有一个在Heroku上托管的Node.js应用程序 . 每次我做 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()从未调用过!错误的ERR!不好的代码undefined npm ERR! cb()从未调用过!错误的ERR!不行的代码1!无法使用npm安装--production依赖项! Heroku推送被拒绝,无法编译Node.js应用程序

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没有任何问题;只有自周一以来我才有这个错误 .

我在网上看过类似的帖子,指的是略有不同的错误,但之前没有看过 ! [remote rejected] master -> master (pre-receive hook declined) .

25 回答

  • 3

    如果你有npm版本5或更高版本,请先尝试:

    $ sudo npm cache verify
    

    除此以外:

    $ sudo npm cache clean
    

    我的节点和npm版本是:

    $ node -v
    v0.10.0
    
    $ npm -v
    1.2.14
    

    https://docs.npmjs.com/cli/cache

  • 13

    对于在2013年9月29日左右访问此页面的任何人,Node.js 0.10.19中存在一个已关闭的错误,导致此错误 .

    https://github.com/isaacs/npm/issues/2907#issuecomment-15215278 https://github.com/joyent/node/issues/6263#issuecomment-25113849

    如果你在Heroku上,你应该升级到0.10.20

    "engines": {
        "node": "0.10.20"
    }
    
  • 0

    您的 package.json 中是否在 "engines" 下指定了 "npm" 的特定版本?听起来像NPM v1.2.15 resolved the issue(和Heroku可用) . "1.1.x" 我遇到了同样的问题 .

  • 0

    我在尝试为WordPress安装Sage主题时遇到了这个问题 . 当我在主题目录上运行 npm install 时,它失败了 .

    查看 package.json 中的依赖项,我可以看到我为Node运行的引擎已经过时了 . 在命令行上运行 node -v 显示我在v0.10.9上,最新版本的Sage需要> = 0.12.0

    所以这是解决这个问题的方法 . 这些步骤来自David Walsh's blog

    • 清除你的npm缓存: sudo npm cache clean -f

    • 安装最新版本的Node helper: sudo npm install -g n

    • 告诉帮助者(n)安装最新的稳定版Node: sudo n stable

    然后,您应该获得进度显示,之后您将获得最新信息 .

    当我在执行此操作后运行 npm install 时,一切正常,我能够运行 gulp 来构建最初的 dist 目录 .

  • 1

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

    至少对我来说,它似乎是由网络问题(下载损坏)引起的 . 我也收到有关无效程序包的错误,我可以通过删除“tmp.tgz”的所有实例来解决这个问题 .

    编辑:(可能不相关,但万一这有助于任何人:我使用Windows,并在收到初始错误后以管理员身份启动命令提示符) .

  • 3

    我在安装 ionic@beta 时遇到了同样的问题 . 我尝试了以下项目,他们没有帮助我 .

    • npm cache clean

    • %temp%\npm-* 手动删除缓存

    • 命令提示符"Run As Administrator"

    我通过安装node-v5.10.1-x64.msi(以前的版本是node-v5.9.0-x64.msi)并在安装 ionic@beta 之前运行 npm cache clean 解决了这个问题

    有效!

  • 0

    更新NodeJS https://nodejs.org/en/修复了我的问题 .

    运行 npm install -g npmnpm cache clean

  • 2

    尝试

    sudo npm cache clean --force
    
  • 0

    sudo npm cache clean 对我不起作用 . 更新到最新版本的节点有帮助 .

    我有节点v.5.91并更新到v6.9.1

  • 1

    看来特定的依赖版本可能会导致此问题 . 例如,gulp-uglifycss 1.0.7有这个问题(参见https://github.com/rezzza/gulp-uglifycss/issues/15) .

    如果您允许通过 ^~packages.json 中进行主要或次要版本更新,请删除文件中的这些字符并尝试另一个 npm install . 如果它的工作时间那么你就可以在缩小哪个软件包引起问题之后就可以了 .

  • 208

    如果您已更新angular cli,npm,node,则无需执行任何操作 . 只需运行以下命令即可解决问题 . 此命令还解决了“意外结束”的问题 .

    npm install --no-package-lock
    
  • 22

    拿起mdp离开的地方,问题在于节点0.10.19和npm 1.3.11

    我找到了最简单的方法来管理降级以保持顺利进行NVMhere是一个很好的教程如何使用它 . 我使用NVM在几分钟内修改了服务器环境并正确地将其从0.10.19降级到0.10.18 .

  • 3

    Run it without thinking

    npm cache clean -f

    npm install -g n

    n stable

    npm install -g angular-cli

  • 8

    我刚刚全球安装了最新版本的NPM,它对我有用 . 我猜清除npm缓存是可选的 .

    npm install -g npm
    
  • 6
    • 运行 npm install -g npm

    • 然后运行 npm install

  • 2
    brew uninstall node
    cd /usr/local
    git checkout f7bbdcc /usr/local/Library/Formula/node.rb
    brew install node
    

    找到其他版本:

    brew versions node
    
  • 1

    npm install npm@latest -g 将npm更新为最新版本 . 这解决了我的问题 . 我先做了 npm cache clean

  • 1

    npm install 会导致:

    npm ERR! cb() never called!
    
    npm ERR! This is an error with npm itself. Please report this error at:
    npm ERR!     <https://github.com/npm/npm/issues>
    

    在我的情况下,当我升级到Node.js版本 8.11.1 时,此错误开始发生 . 以前使用Node.js版本 6.12.x 和NPM版本 5.8.0 .

    除此之外,我的测试脚本找不到AVA:

    sh: ava: command not found
    npm ERR! Test failed.  See above for more details.
    

    解决方案是将NPM降级为 5.7.1

  • 5

    尝试在我的Windows笔记本电脑中安装firebase-tools时遇到了同样的问题 . 这就是我解决它的方式 .

    • 我下载了卡巴斯基并安装了它 . 然后我禁用了卡巴斯基安全连接

    • 我打开cmd并运行此命令 npm cache clean --force

    • 我然后运行此命令 npm install npm@latest -g

    • 我然后运行firebase cli命令 npm install -g firebase-tools

  • 0

    对于我来说,npm 6.4.0 和节点 10.9.0 没有任何答案奏效 . 重新安装节点,npm,清理缓存,删除文件夹......

    经过一些调试后发现我使用了 npm link 来开发我正在开发的两个模块来相互链接 . 一旦我删除并重新编写了一些链接,我就可以重新开始工作了 .

  • 8

    对于特定配置或节点版本,似乎没有出现此问题 . 我们在重新部署并怀疑npm服务器导致此问题时经历了几次 .

    重试几次确实最终解决了这个问题 .

  • 2

    可能有两种可能性=>

    • 尝试更新节点js和npm .

    • 权限问题=> a . 在各自的用户帐户中移动c驱动器上的解决方案b . 需要以管理员身份运行bash或cmd .

    希望这能解决您的问题

  • 138

    我在Mac上遇到了同样的问题,我尝试了所有可以找到的方法:升级到最新的Node,清理缓存,删除_node_mudules_目录,但都没有效果 . 最后,我认为这是Node环境的问题,所以我将我的Node降级为旧的LTS版本6.14.1,然后问题就消失了 . 这就是我做的:

    • 安装NVM(要获得全新的隔离节点环境,最好使用NVM管理多个节点环境,有关详细信息,请转至here

    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

    • 安装Node.js 6.14.1

    nvm install 6.14.1

    • 切换到上面安装的特定节点环境

    nvm use 6.14.1

    • 安装create-react-app

    npm install -g create-react-app

    • 创建您的反应应用

    create-react-app appname

  • 2

    检查系统路径变量中是否有 npm npm 命令 .

    在我的例子中,我在Node安装目录中有一个版本,在 npm globals 安装目录中有一个旧版本(在npm配置文件中称为 prefix ) . 所以我检查了 npm config get prefix 的位置,并从node_modules中删除了链接和 npm 文件夹 . (删除另一个也可能有效,具体取决于PATH变量中的顺序 . )

  • 1

    [作品]尝试npm config删除https-proxy

    它会与代理冲突 .

相关问题