【已解决】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.

一. 问题描述

用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

二. 问题解决

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

  1. 删除下载好的node_modules
  2. 删除package-lock.json文件
  3. 清除npm缓存 npm cache clean --force
  4. npm install

三. 注意事项

另外,使用这个方法的前提条件就是你的npm源可连接并且有权限获取到里代码里使用的包,
并且解决了之前的报错问题,如果没有有权限,请修改包版本或者修改npm源。

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

  1. 修改包版本
    npm 安装指定版本的包
    使用 包名@版本号 指定,
    例如,安装 Express 3.21.2,
$ npm install express@3.21.2
  1. 修改npm源为淘宝源或者可以用的其他源
//查看源
npm config get registry
//更换源
npm config set registry https://registry.npmjs.org
//淘宝源
npm config set registry https://registry.npm.taobao.org
  • 16
    点赞
  • 36
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值