关于window上出现npm ERR! cb()never called!的错误

在运行npm install -g grunt-cli 时,由于时国外的服务器,用于很长时间没有下载下来,取消重新下载之后报如下错误:

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!     /Users/lenno/.npm/_logs/2019-04-04T08_14_08_150Z-debug.log

然后一顿搜索之后,让试这个试那个的命令,一脸懵逼,看到“npm cache verify”这个帮助了不少人,然后自己尝试执行了一下,然后在执行“npm install -g grunt-cli”,莫名其妙就好了,很快就下载下来了,记录一下,方便以后解决。

最后整理了一下,在window和linux 上如何解决这个问题

Linux:

以管理员模式打开cmd清除你的npm缓存 (mac电脑在npm前加sudo):

npm cache clean -f

清除完缓存后,安装最新版本的Node helper:

 npm install -g n

然后安装npm包管理助手

npm install -g n --force

用n助手安装最新的稳定版的node

n stable

Window:

刚开始按照上面的操作了一边最后在执行  n stable 时出现bash不是内部不命令,查看文件夹之后发现 n 是一个shell脚本,在命令行执行不了

1.先使用:npm cache verify

2.在使用:npm cache clean

3.可能需要:npm cache clean -—force

重新进行安装需要的包即可

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章