安装Mongoose遇npm ERR! cb() never called!错误求助
解决npm install mongoose时出现"cb() never called!"错误
问题详情
执行npm install mongoose时终端抛出如下错误:
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! https://npm.communitynpm ERR! A complete log of this run can be found in:
npm ERR! /home/kimmy/.npm/_logs/2023-01-27T13_01_37_127Z-debug.log
完整错误日志:
0 info it worked if it ends with ok 1 verbose cli [ 1 verbose cli '/home/kimmy/.nvm/versions/node/v14.21.2/bin/node', 1 verbose cli '/home/kimmy/.nvm/versions/node/v14.21.2/bin/npm', 1 verbose cli 'install', 1 verbose cli 'mongoose' 1 verbose cli ] 2 info using npm@6.14.17 3 info using node@v14.21.2 4 verbose npm-session 8ab7c7a226abac11 5 silly install loadCurrentTree 6 silly install readLocalPackageData 7 http fetch GET 200 https://registry.npmjs.org/mongoose 105321ms 8 timing npm Completed in 139026ms 9 error cb() never called! 10 error This is an error with npm itself. Please report this error at: 11 error <https://npm.community>
环境信息:
- Node.js版本:v10.19.0
- npm版本:6.14.17
已尝试操作:删除node_modules和package-lock.json后重新安装,重新安装npm,问题未解决。
解决方案
对齐Node.js版本:日志显示实际运行的Node.js是v14.21.2,与你声明的v10.19.0不一致,版本冲突会导致npm运行异常。执行命令切换到指定版本:
nvm use 10.19.0切换后验证版本:
node -v && npm -v清理npm缓存:缓存损坏可能引发此类问题,执行强制清理:
npm cache clean --force安装兼容版本的mongoose:Node.js v10不支持mongoose v6及以上版本,安装适配的v5.x版本:
npm install mongoose@5.13.20重置npm配置:若网络或配置异常,重置npm默认配置:
npm config delete proxy npm config delete https-proxy npm config set registry https://registry.npmjs.org/
内容的提问来源于stack exchange,提问作者Kimi Casamina
相关产品推荐
相关产品推荐

