npm ERR! cb() never called! npm ERR! This is an error with npm itself.

在使用npm install安装依赖时报错

Error while executing: npm ERR! D:\Program Files\Git\cmd\git.EXE ls-remote -h -t git://github.com/ad

我们需要设置git环境

git config --global url."https://".insteadOf git://

然后重新运行 npm install就行或者npm install --registry=https://registry.npm.taobao.org使用淘宝镜像


npm安装依赖报错: npm ERR! cb() never called! npm ERR! This is an error with npm itself.
一. 问题描述
用npm安装依赖时报错,如下:

npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2020-12-16T07_38_47_793Z-debug.log


二. 问题解决
这个问题困扰了我几天,网上答案五花八门,不过对我来说,那些方法都没有效果,记录一下我解决这个错误的步骤,如下:

删除下载好的node_modules
删除package-lock.json文件
清除npm缓存 npm cache clean --force
npm install
三. 注意事项
另外,使用这个方法的前提条件就是你的npm源可连接并且有权限获取到里代码里使用的包,
并且解决了之前的报错问题,如果没有有权限,请修改包版本或者修改npm源。

这个步骤在npm install之前,清除缓存之后操作。

修改包版本
npm 安装指定版本的包
使用 包名@版本号 指定,
例如,安装 Express 3.21.2,
$ npm install express@3.21.2


修改npm源为淘宝源或者可以用的其他源
//查看源
npm config get registry
//更换源
npm config set registry https://registry.npmjs.org
//淘宝源
npm config set registry https://registry.npm.taobao.org

 

posted @   小忱  阅读(6954)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
点击右上角即可分享
微信分享提示