npm ERR cb()从未调用

node.js Node.js

小宇宙

2020-03-20

我在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()从未调用过!npm ERR!错误代码未定义npm ERR!cb()从未调用过!npm 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)

第2487篇《npm ERR cb()从未调用》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

30个回答
十三Harry神无 2020.03.20

我遇到了cb() never called!错误,这里没有答案直接对我有用。我正在运行Node v8.11.2,并且必须手动删除该package-lock.json文件才能到达任何地方。完成此操作后,我会npm cache verify按照建议的答案进行操作。然后,运行npm i产生以下结果:

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN securities-stub@1.0.0 No description
npm WARN securities-stub@1.0.0 No repository field.

up to date in 5.118s
前端Harry十三 2020.03.20
brew uninstall node
cd /usr/local
git checkout f7bbdcc /usr/local/Library/Formula/node.rb
brew install node

查找类似的其他版本:

brew versions node
小宇宙 2020.03.20

就我而言,我无法安装VueJS插件,而我必须:

更改文件的所有权:

须藤弦-R $(whoami)〜/ .npm

须藤chown -R $(whoami)/ usr / local / lib

须藤chown -R $(whoami)/ usr / local / bin

然后确保最新的npm:

npm install -g npm @ latest

然后安装我的插件,在您的情况下,您的命令可能是无效的。

小胖 2020.03.20

请执行npm install npm@latest -g以将npm更新为最新版本。这为我解决了问题。我做npm cache clean第一

老丝 2020.03.20

似乎在特定配置或节点版本中不会发生此问题。重新部署时,我们经历了几次,并怀疑npm服务器会导致此问题。

重试几次确实解决了问题。

小宇宙 2020.03.20

[Works]尝试npm config删除https-proxy

它会与代理冲突。

小哥神无 2020.03.20

在mdp离开的地方取货,问题出在节点0.10.19和npm 1.3.11

我找到了管理降级以使其顺利运行为NVM的最简单方法是一个很好的使用方法教程。我使用NVM在短短几分钟内就修改了服务器环境,并可以正确地将其从0.10.19降级到0.10.18。

斯丁 2020.03.20

我建议: 切换到Yarn!- 纱线是使用相同的软件包管理器package.json的文件和node_modules文件夹NPM。

使用npm时,我遇到了同样的问题:在CentOS 6安装上,我ERR cb() never called反复出现错误,并且找不到使npm 可靠地完成某些软件包安装的方法(webpack例如)。-即使在不稳定的网络连接上,纱线也能完美工作。

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

卡卡西Near 2020.03.20

我在Mac上遇到了相同的问题,并且尝试了所有可以找到的方法:升级到最新的Node,清理缓存,删除_node_mudules_目录,但所有方法均无效。最终,我认为这是Node环境的问题,因此我将Node降级为旧的LTS版本6.14.1,然后问题消失了。这是我的工作:

  1. 安装NVM(要获得全新的隔离节点环境,最好使用NVM来管理多个节点环境, 有关详细信息,请转到此处

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

  2. 安装Node.js 6.14.1

    nvm install 6.14.1

  3. 切换到上面安装的特定Node环境

    nvm use 6.14.1

  4. 安装create-react-app

    npm install -g create-react-app

  5. 创建您的应用

    create-react-app appname

Gil 2020.03.20

我今天也遇到了同样的问题,因为由于互联网问题,我迫使两次下载之间的npm软件包停止。

我尝试了各种事情,

  1. 运行sudo npm cache clean -f-无法正常工作
  2. 清理卸载节点并重新安装-这同样行不通

我终于尝试删除包含创建问题的npm缓存的文件夹。我运行了以下命令,

sudo rm -rf /Users/{user_system_user}/.npm/

然后,我尝试安装被卡住的软件包,并且一切正常。

PS:根据系统的当前用户替换{user_sytem_user}。

古一 2020.03.20

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

阿飞 2020.03.20

对于最近从6.x升级到6.7.0的任何人。

删除/Users/{YOUR USERNAME}/.npm文件夹可以解决我的问题npm install

我还运行了https://npm.community/t/crash-npm-err-cb-never-call/858/93?u=jasonfoglia建议的一些命令

sudo npm cache clean -f
sudo npm install -g n

但是在删除文件夹之前,我不确定哪个真正有效。因此,如果您遇到此问题,而只是删除解决您的问题的.npm文件夹,请注意在注释中。

SamSam老丝 2020.03.20

对于Ubuntu用户,以下给定的方法对我有用。

首先,执行以下操作: sudo npm cache verify

然后转到Home->。npm并通过以下方式删除_cache文件夹: sudo rm -rf _cacache/

去检查一下,也许您找到了解决方案。

神无 2020.03.20

我刚刚在全球范围内安装了最新版本的NPM,并且对我有用。我想清除npm缓存是可选的。

npm install -g npm
宝儿理查德 2020.03.20

尝试在Windows笔记本电脑中安装firebase-tools时遇到相同的问题。这就是我解决的方法。

  1. 我下载了卡巴斯基并安装了它。然后我禁用了卡巴斯基安全连接
  2. 我打开cmd并运行此命令 npm cache clean --force
  3. 然后我运行此命令 npm install npm@latest -g
  4. 然后我运行firebase cli命令 npm install -g firebase-tools
GreenA 2020.03.20

似乎特定的依赖项版本可能会导致此问题。例如,gulp-uglifycss 1.0.7就有此问题(请参阅https://github.com/rezzza/gulp-uglifycss/issues/15)。

如果您允许在packages.jsonvia ^中进行主要或次要版本更新,请~在文件中删除这些字符,然后尝试另一个npm install如果那段时间行得通,那么在缩小导致问题原因的软件包的范围之后,您会没事的。

老丝 2020.03.20

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

经过一些调试,结果证明我使用npm link了两个开发中的模块相互链接。一旦删除并重新链接了一些链接,我便可以使它们重新工作。

斯丁前端 2020.03.20

sudo npm cache clean没有为我工作。更新到最新版本的节点帮助。

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

神乐小宇宙Gil 2020.03.20

对我来说,以上解决方案均无效(重新安装,清除缓存,文件夹等)。

我的问题已解决:

npm config set registry https://registry.npmjs.org/
西里神奇 2020.03.20

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

  1. npm cache clean
  2. 从中手动删除缓存 %temp%\npm-*
  3. 命令提示符“以管理员身份运行”

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

有效!

猪猪 2020.03.20

我在NPM版本1.3.11中遇到了相同的问题,只需多次重复运行完全相同的命令即可解决此问题(本例中为“ npm update -g”)。在随后的每次运行中,针对不同的程序包都会弹出该错误,并最终成功更新所有内容。

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

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

番长樱梅 2020.03.20

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

运行npm install -g npmnpm cache clean

神奇小哥西里 2020.03.20
  • npm install -g npm
  • 然后跑 npm install
Near小胖 2020.03.20

如果您已更新了角度cli,npm,node,则无需执行其他任何操作。只需运行以下命令即可解决该问题。此命令还解决了“意外的行尾”问题。

npm install --no-package-lock
西里斯丁 2020.03.20

你有一个特定版本的"npm"规定下,"engines"在你的package.json听起来像NPM v1.2.15 解决了该问题(Heroku已可用)。我遇到了同样的问题"1.1.x"

前端Eva 2020.03.20

尝试

sudo npm cache clean --force
樱小胖Mandy 2020.03.20

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

查看中的依赖项package.json,我可以看到我为Node运行的引擎已经过时。node -v在命令行上运行表明我使用的是v0.10.9,最新版本的Sage要求> = 0.12.0

所以这是解决方法。这些步骤来自David Walsh的博客

  1. 清除您的npm缓存: sudo npm cache clean -f
  2. 安装最新版本的Node helper: sudo npm install -g n
  3. 告诉助手(n)安装最新的稳定版Node: sudo n stable

然后,您应该获得进度显示,之后您将保持最新状态。

当我跑npm install这样做之后,一切工作正常,我是能够运行gulp构建初始dist目录。

Gil伽罗小宇宙 2020.03.20

尝试清除npm缓存:

sudo npm cache clean --force
小胖 2020.03.20

对于在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"
}
Tom西里路易 2020.03.20

如果您具有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

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android