node.js npm ERR cb() 从未调用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15393821/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm ERR cb() never called
提问by Louise K
I have a Node.js app hosted on Heroku. Every time I do a git push herokuI get the following error:
我在 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
> [email protected] 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
> [email protected] 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 [email protected]:still-chamber-1286.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:still-chamber-1286.git'
The error is in the last few lines: 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
错误在最后几行:npm ERR!cb() 从未调用过!npm 错误!不行代码未定义 npm ERR!cb() 从未调用过!npm 错误!代码 1 不行!无法使用 npm 安装 --production 依赖项!Heroku 推送被拒绝,无法编译 Node.js 应用程序
To [email protected]:still-chamber-1286.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:still-chamber-1286.git'
I have had no problems with pushing my code to Heroku before; only since Monday have I had this error.
我之前在将代码推送到 Heroku 方面没有遇到任何问题;直到星期一我才遇到这个错误。
I have seen similar posts on the web referring to slightly different errors, but haven't seen one with ! [remote rejected] master -> master (pre-receive hook declined)before.
我在网上看到过类似的帖子,提到的错误略有不同,但以前从未见过! [remote rejected] master -> master (pre-receive hook declined)。
回答by Alberto
If you have npm version 5 or above, try this first:
如果您有 npm 5 或更高版本,请先尝试以下操作:
$ sudo npm cache verify
Otherwise:
除此以外:
$ sudo npm cache clean
My node and npm versions are:
我的节点和 npm 版本是:
$ node -v
v0.10.0
$ npm -v
1.2.14
回答by Mark Percival
For anyone hitting this page around Sept 29th, 2013, there's a closed bug in Node.js 0.10.19 which is causing this error.
对于在 2013 年 9 月 29 日左右访问此页面的任何人,Node.js 0.10.19 中存在导致此错误的已关闭错误。
https://github.com/isaacs/npm/issues/2907#issuecomment-15215278https://github.com/joyent/node/issues/6263#issuecomment-25113849
https://github.com/isaacs/npm/issues/2907#issuecomment-15215278 https://github.com/joyent/node/issues/6263#issuecomment-25113849
If you're on Heroku you should upgrade to 0.10.20
如果你在 Heroku 上,你应该升级到 0.10.20
"engines": {
"node": "0.10.20"
}
回答by SanS
try
尝试
sudo npm cache clean --force
回答by Appsol Zone
Try clearing your npm cache:
尝试清除您的 npm 缓存:
sudo npm cache clean --force
回答by Aidan Feldman
Do you have a specific version of "npm"specified under "engines"in your package.json? Sounds like NPM v1.2.15 resolved the issue(and Heroku has available). I was getting the same problem with "1.1.x".
你有一个特定版本的"npm"规定下,"engines"在你的package.json?听起来 NPM v1.2.15解决了这个问题(Heroku 已经可用)。我遇到了同样的问题"1.1.x"。
回答by raffjones
IMPORTANT!The solution below is now regarded as unstable, and you should use Node Version Management instead: Node Version Manager on Github. David Walsh also has a good introduction to NVM. NVM works beautifully and I've been using it to manage legacy WordPress projects for a few years.
重要的!下面的解决方案现在被认为是不稳定的,你应该改用节点版本管理:Github 上的节点版本管理器。David Walsh对 NVM也有很好的介绍。NVM 运行良好,几年来我一直在使用它来管理旧的 WordPress 项目。
Please don't use this - use NVM
请不要使用这个 - 使用 NVM
I just had this exactly issue when trying to install the Sage theme for WordPress. When I ran npm installon the theme directory, it failed.
我在尝试为 WordPress 安装 Sage 主题时遇到了这个问题。当我npm install在主题目录上运行时,它失败了。
Looking in the dependencies in package.json, I could see that the engine I was running for Node was out of date. Running node -von the command line showed that I was on v0.10.9, and the latest version of Sage requires >= 0.12.0
查看 中的依赖项package.json,我可以看到我为 Node 运行的引擎已过时。node -v命令行运行显示我是v0.10.9,最新版本的Sage需要>=0.12.0
So here's the fix for that. These steps are from David Walsh's blog
所以这是解决这个问题的方法。这些步骤来自David Walsh 的博客
- Clear your npm cache:
sudo npm cache clean -f - Install the latest version of the Node helper:
sudo npm install -g n - Tell the helper (n) to install the latest stable version of Node:
sudo n stable
- 清除你的 npm 缓存:
sudo npm cache clean -f - 安装最新版本的 Node 助手:
sudo npm install -g n - 告诉助手 (n) 安装最新的稳定版 Node:
sudo n stable
You should then get a progress display, after which you will be up to date.
然后您应该会看到一个进度显示,之后您将是最新的。
When I ran npm installafter doing this, everything worked fine, and I was able to run gulpto build the initial distdirectory.
当我npm install执行此操作后,一切正常,并且我能够运行gulp以构建初始dist目录。
回答by Solution Spirit
- Run
npm install -g npm - Then run
npm install
- 跑
npm install -g npm - 然后运行
npm install
回答by chetan shah
If you have updated angular cli, npm, node, you don't need to do anything more. Just run the command below to resolve the issue. This command also resolves the issue of "unexpected end of line".
如果您已经更新了 angular cli、npm、node,则无需再执行任何操作。只需运行以下命令即可解决问题。此命令还解决了“意外结束行”的问题。
npm install --no-package-lock
回答by Srinivas
Updating the NodeJS https://nodejs.org/en/Fixed My Issue.
更新 NodeJS https://nodejs.org/en/修复了我的问题。
Run npm install -g npm& npm cache clean
运行npm install -g npm&npm cache clean
回答by Sen Jacob
I had the same problem while installing ionic@beta.
I tried the following items and they didn't help me.
我在安装时遇到了同样的问题ionic@beta。我尝试了以下项目,但它们没有帮助我。
npm cache clean- Manually delete cache from
%temp%\npm-* - Command prompt "Run As Administrator"
npm cache clean- 手动删除缓存
%temp%\npm-* - 命令提示符“以管理员身份运行”
I solved the problem by installing node-v5.10.1-x64.msi (Previous version was node-v5.9.0-x64.msi) and run an npm cache cleanbefore installing ionic@beta
我通过安装 node-v5.10.1-x64.msi(以前的版本是 node-v5.9.0-x64.msi)解决了这个问题并npm cache clean在安装之前运行ionic@beta
It worked!
有效!

