npm错误cb()从未调用

我有一个在Heroku上托pipe的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! 不好的代码undefined npm ERR! cb()从不叫! npm ERR! 不好,代码1! 无法安装 – 生产依赖与npm! 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上的问题; 只有自周一以来我有这个错误。

我在网上看到类似的post提到略有不同的错误,但没有看到与! [remote rejected] master -> master (pre-receive hook declined) ! [remote rejected] master -> master (pre-receive hook declined)之前。

这个解决方法为我工作:

 $ sudo npm cache clean 

我的节点和npm版本是:

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

npmjs.org/doc/cache.html

对于2013年9月29日左右打开此页面的人来说,Node.js 0.10.19中存在一个closures的错误,导致了这个错误。

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" } 

你有没有在package.json "engines"下指定的特定版本的"npm" ? 听起来像NPM v1.2.15 解决了这个问题 (和Heroku可用)。 我遇到了与"1.1.x"相同的问题。

我和NPM版本1.3.11有同样的问题,并且通过多次重新运行完全相同的命令(在我的情况下是“npm update -g”)解决了这个问题。 在随后的每次运行中popup一个不同的程序包错误,并最终成功更新所有内容。

至less对我来说,这似乎是由networking问题(损坏的下载)造成的。 我也遇到了一个关于无效包的错误,我可以通过删除“tmp.tgz”的所有实例来解决这个错误。

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

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

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

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

有效!

当试图安装WordPress的Sage主题时,我只是有这个问题。 当我在主题目录上运行npm install时,失败了。

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

所以这是对此的修复。 这些步骤来自David Walsh的博客

  1. 清除你的npmcaching: sudo npm cache clean -f
  2. 安装最新版本的节点助手: npm install -gn
  3. 告诉帮手(n)安装Node的最新稳定版本: sudo n stable

你应该得到一个进度显示,在此之后,你将会是最新的。

当我这样做后,运行npm install ,一切正常,我能够运行gulp构build最初的dist目录。

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

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

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

我发现最简单的方法来pipe理降级,以保持顺利进行NVM , 这是一个很好的教程如何使用它。 我已经修改了服务器环境,并在几分钟内使用NVM从0.10.19正确地降级到了0.10.18。

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

运行npm install -g npmnpm cache clean

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

如果您允许通过^~packages.json中进行主版本或次版本更新,请删除整个文件中的这些字符,然后尝试另一个npm install 。 如果这个时间有效的话,那么在缩小哪个软件包导致问题的乐趣之后,你会没问题的。

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

find像这样的其他版本:

 brew versions node 

运行它没有想到

npm cache clean -f

npm install -gn

n stable

npm install -g angular-cli

看起来像这个问题没有发生在一个特定的configuration或节点版本。 当重新部署和怀疑npm服务器导致这个问题时,我们经历了几次。

重试了几次,最终解决了这个问题。

npm install npm@latest -g将npm更新到最新版本。 这为我解决了这个问题。 我确实先做npm cache clean

可能有两种可能性=>

  1. 尝试更新您的节点js和npm。

  2. 权限问题=> a。 将您的解决scheme移到您的相应用户帐户的c盘上。 需要以pipe理员身份运行bash或cmd。

希望这将解决您的问题

我只是全球安装了最新版本的NPM,它为我工作。 我想清除npmcaching是可选的。

 npm install -g npm