针对 npm ERR! cb() never called! 问题
出现问题的场景:
1接手新项目,先是通过cnpm install安装依赖,然后node-sass一直显示下载中,无法完成安装
2使用npm+镜像安装
npm install --registry=https://registry.npm.taobao.org
解决方法:
一、首先要以管理员模式打开cmd清除你的npm缓存 : npm cache clean -f
二、清除完缓存后,安装最新版本的Node helper: npm install -g n
如果出现错误 npm install -g n --force
再次重新安装,采用npm+镜像地址
npm install --registry=https://registry.npm.taobao.org
然后,npm run dev跑项目,提示需要安装node-sass
然后npm install node-sass下载失败,一直卡在下载中页面
解决Cannot download "https://github.com/sass/node-sass/releases/download...问题
网上有人通过修改环境变量,可以问题,然后我去本地npm缓存目录查询
C:\Users\%username%\AppData\Roaming\npm-cache
然后发现我的本地缓存没有文件,这种方法不适应
参考:https://blog.youkuaiyun.com/lx1996082566/article/details/87901958
node.js报错 Windows 64-bit with Node.js,问题来了,怎么下载node-sass
尝试 npm rebuild node-sass 依旧下载失败
网上找贴,解决方案,亲测有效:
(1)运行: npm uninstall node-sass 卸载安装失败的node-sass
(2)运行: npm install -g node-gyp
(3)运行: npm install --global --production windows-build-tools
注:可能报很多npm ERR!,我没管,后面依旧能运行。
(4)运行: npm install node-sass 重新安装
参考:https://blog.youkuaiyun.com/weixin_44671176/article/details/103493274
这时下载的是5.0版本的sass,运行报错出现版本不适配问题:
Node Sass version 5.0.0 is incompatible with^4.0.0
解决方案:卸载最新的版本,然后安装指定版本
npm uninstall node-sass //卸载node-sass
npm install node-sass@4.14.1 //安装项目匹配的sass版本
参考:https://blog.youkuaiyun.com/weixin_49218696/article/details/109443978
然后查看电脑目录: C:\Users\%username%\AppData\Roaming\npm-cache