我有一个托管在 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() 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 没有任何问题;仅从星期一开始,我才出现此错误。
我在网上看到过类似的帖子,其中提到了略有不同的错误,但之前没有见过带有 ! [remote rejected] master -> master (pre-receive hook declined)
的帖子。
! [remote rejected] master -> master (pre-receive hook declined)
"engines": { "node": "0.8.x" }
添加到我的 package.json
为我修复了该错误。
package.json
中已经有 "engines": { "node": "0.6.x" }
,但我只需将它从 0.6.x
更改为 0.8.x
$> npm install -g npm
) 为自己解决了这个问题,因为我收到警告说软件包在控制台输出中无论如何都需要更高版本。
如果你有 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
对于在 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"
}
-g
安装 (wintersmith) 时,它失败并出现此错误。如果我先安装时没有全局选项,然后再安装它,我没有收到错误消息。
尝试
sudo npm cache clean --force
更多信息请参阅:https://reactgo.com/npm-err-cb-never-called/
npm cache clean --force
在我的本地实例中对我有用并解决了此错误消息。谢谢!
如果你已经更新了 angular cli、npm、node,你就不需要再做任何事情了。只需运行以下命令即可解决问题。此命令还解决了“意外的行尾”问题。
npm install --no-package-lock
重要提示!以下解决方案现在被认为是不稳定的,您应该改用节点版本管理:Node Version Manager on Github。大卫沃尔什也有一个good introduction to NVM。 NVM 运行良好,几年来我一直在使用它来管理遗留的 WordPress 项目。
请不要使用这个 - 使用 NVM
我在尝试为 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 助手:sudo npm install -gn 告诉助手 (n) 安装最新的稳定版 Node:sudo n stable
然后,您应该会看到进度显示,之后您将获得最新信息。
当我在执行此操作后运行 npm install
时,一切正常,并且我能够运行 gulp
来构建初始 dist
目录。
sudo npm install -g n
。
您的 package.json
中的 "engines"
下是否指定了特定版本的 "npm"
?听起来像 NPM v1.2.15 resolved the issue(并且 Heroku 已经可用)。 "1.1.x"
我遇到了同样的问题。
运行 npm install -g npm
然后运行 npm install
cb() never called!
时不起作用。
更新 NodeJS https://nodejs.org/en/ 解决了我的问题。
运行 npm install -g npm
& npm cache clean
对我来说,上述解决方案都不起作用(重新安装、清除缓存、文件夹等)。
我的问题通过以下方式解决:
npm config set registry https://registry.npmjs.org/
npm config set registry https://registry.npmjs.org/
更新:这个问题很常见,这是新的修复 npm cache verify
运行,你会很高兴!
npm version: 6.14.14
node version: v14.17.5
时遇到了这个问题,以上解决方案有效!谢谢 :-)
我在安装 ionic@beta
时遇到了同样的问题。我尝试了以下项目,但它们没有帮助我。
npm cache clean 从 %temp% 手动删除缓存\npm-* 命令提示符“以管理员身份运行”
我通过安装 node-v5.10.1-x64.msi(以前的版本是 node-v5.9.0-x64.msi)解决了这个问题,并在安装 ionic@beta
之前运行 npm cache clean
有效!
从 NPM 6 开始,您可以进行全新安装。那是唯一对我有用的解决方案。
只需运行以下命令:
npm clean-install
笔记:
您也可以手动删除 node_modules 文件夹,然后重试以防上述命令失败。
如果仍然不起作用,则全局缓存可能已损坏,请尝试运行 npm cache clean --force 然后进行全新安装。
clean-install 命令适用于 npm 6 及更高版本。对于旧版本,请考虑检查下面的其他答案。
[作品] 试试
npm config delete https-proxy
它会与代理冲突。
我在使用 NPM 1.3.11 版时遇到了同样的问题,只需通过多次重新运行完全相同的命令来解决它(在我的例子中是“npm update -g”)。每次后续运行时都会针对不同的包弹出错误,并最终成功更新所有内容。
至少对我来说,这似乎是由网络问题(下载损坏)引起的。我还收到有关无效包的错误,我可以通过删除“tmp.tgz”的所有实例来解决该错误。
编辑:(可能不相关,但如果这对任何人都有帮助:我使用的是 Windows,并在收到初始错误后以管理员身份启动了命令提示符)。
我有 cb() never called!
错误,这里没有一个答案直接对我有用。我正在运行节点 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
截至 2021 年 3 月,新的 NPM 版本修复了其中许多问题。
所以调用 npm i -g npm@latest
再次解决了这个问题(在这之间不起作用)。
如果在运行 npm cache clean --force
后错误仍然存在,请尝试在切换到其他网络后重新运行 npx create-react-app your_app_name
。由于网络缓慢且不稳定,此错误也可能导致...
我刚刚全局安装了最新版本的 NPM,它对我有用。我猜清除 npm 缓存是可选的。
npm install -g npm
对我来说,在 npm 6.4.0
和节点 10.9.0
上,没有一个答案有效。重新安装节点、npm、清理缓存、删除文件夹...
经过一些调试后,我发现我使用 npm link
让我正在开发的两个模块相互链接。一旦我删除并重新创建了一些链接,我就可以让它再次正常工作。
知道这是一个老问题,你们中的许多人已经提供了答案。只是为了分享我对这个错误的经验以及我是如何修复的。
这一切都是在我将 Node 版本升级到 > 之后开始的。 12,我确实浏览了所有答案并尝试按照步骤清除 npm
缓存,删除 node_modules
文件夹。他们没有一个能解决我的问题。
在我的情况下,根本原因是代理限制安装。我删除了代理设置以解决问题。
检查您是否有任何代理配置 npm config list 通过 npm config delete proxy npm config delete http-proxy npm config delete https-proxy 现在尝试 npm install
对我有用的是:删除 package-lock.json 文件并运行以下命令:
npm 缓存清理 --force
sudo npm cache clean
不适合我。更新到最新版本的节点有帮助。
我有节点 v.5.91 并更新到 v6.9.1
我建议:切换到 Yarn! - Yarn 是一个包管理器,它使用与 npm 相同的 package.json
文件和 node_modules
文件夹。
使用 npm 我遇到了同样的问题:在 CentOS 6 安装中,我反复收到 ERR cb() never called
错误,无法找到一种方法让 npm 可靠 完成某些软件包的安装(例如 webpack
)。 - 即使在不稳定的网络连接上,Yarn 也能完美运行。
迁移到 Yarn 很容易。大多数子命令是相同的。他们有一个很好的Migration guide。最后阅读方便的 CLI commands comparison。
npm install
问题。当 npm install
失败时,yarn install
在两个不同的项目中解除了对我的阻止!希望我能知道为什么,但是...
我的项目中有同样的错误。我正在研究隔离的 Intranet,因此我的解决方案如下:
运行 npm clean cache --force
删除 package-lock.json
就我而言,我必须在 .npmrc 中设置 NPM 代理
Try switching your network
,不知何故切换网络对我有用。
我尝试了其他答案中提到的许多事情,例如:
npm cache clean --force 删除现有的 node_modules,删除 package-lock.json,然后使用 -npm i npm cache verify npm clean-install 重新安装
None of the above worked for me
,可能对您有用。试试你的运气。
似乎特定的依赖版本可能会导致此问题。例如,gulp-uglifycss 1.0.7 就有这个问题(参见 https://github.com/rezzza/gulp-uglifycss/issues/15)。
如果您允许通过 ^
或 ~
在 packages.json
中进行主要或次要版本更新,请在整个文件中删除这些字符并尝试另一个 npm install
。如果它在那个时候有效,那么在你有乐趣缩小导致问题的包之后你会没事的。
尝试在我的 Windows 笔记本电脑中安装 firebase-tools 时遇到了同样的问题。这就是我解决它的方法。
我下载了卡巴斯基并安装了它。然后我禁用了卡巴斯基安全连接我打开了 cmd 并运行这个命令 npm cache clean --force 我然后运行这个命令 npm install npm@latest -gi 然后运行 firebase cli 命令 npm install -g firebase-tools
npm cache clean --force
--force 帮助清理缓存
对于 Ubuntu 用户,下面给出的方法对我有用。
首先,执行此操作:sudo npm cache verify
然后转到 Home->.npm 并通过以下方式删除 _cache 文件夹:sudo rm -rf _cacache/
去检查一下,也许你找到了解决方案。
我今天也遇到了同样的问题,因为由于互联网问题,我在中间强制停止了 npm 包下载。
我尝试了各种各样的事情,比如,
运行 sudo npm cache clean -f - 没有按预期工作 清理卸载节点并重新安装它 - 也没有工作
我终于尝试删除包含导致问题的 npm 缓存的文件夹。我运行了以下命令,
sudo rm -rf /Users/{user_system_user}/.npm/
然后我尝试安装卡住的软件包,一切都像魅力一样。
PS:根据您系统的当前用户替换{user_sytem_user}
。
如果您在 IntelliJ idea 等 IDE 中打开代码,请关闭并重试
不定期副业成功案例分享