Vue3 解决:npm ERR! network request to https://registry.npmmirror.com/node-sass failed 的三种解决方案

1、问题描述:

其一、整体报错为:
安装的命令为:npm i node-sass

npm ERR! code ETIMEDOUT
npm ERR! syscall connect
npm ERR! errno ETIMEDOUT
npm ERR! network request to https://registry.npmmirror.com/node-sass failed, reason: connect ETIMEDOUT 240e:e9:d804:0:3::3fb:443
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! network request to https://registry.npmmirror.com/node-sass failed, reason: connect ETIMEDOUT 240e:e9:d804:0:3::3fb:443

中文为:

npm 错误! 到 https://registry.npmmirror.com/node-sass 的网络请求失败,原因:连接 ETIMEDOUT 240e:e9:d804:0:3::3fb:443

其二、问题描述为:

想要在 vue3 项目里,支持 <style lang="scss" scoped> 的语言,因此想要 node-sasssass-loader 从而能达到自己的目的,但安装的过程中却报错;

其三、报错面显示为:

在这里插入图片描述

2、问题分析:

其一、根据中文的报错信息:

根据中文报错的信息,能明确是镜像的问题(即:连接的网络的问题),导致访问不到 node-sass 的下载地址;

其二、解决问题的思路:

一般情况下,只有两种解决方案:

A、切换下载 node-sass 等的镜像地址;

B、使用一些指令,使得 node-sass 能成功下载;

3、问题解决:

方式一、切换下载的镜像地址:

A、查看现在地址的命令为:npm config get registry

在这里插入图片描述
B、切换地址的命令为:npm config set registry http://registry.npm.taobao.com

在这里插入图片描述
C、此时的镜像地址为: http://registry.npm.taobao.com

D、再输入命令 npm i node-sass,一般就能解决问题;

方式二、命令切换下载 node-sass 的镜像地址:

A、下载命令为:

npm install node-sass --sass-binary-site=http://npm.taobao.org/mirrors/node-sass

B、此时一般就能解决问题;

方式三、如果上述两步的操作并没有解决问题,那么可试下重启一下电脑:

此时再输入命令 npm i node-sass,一般就能解决问题;


     注意:在 vue3 的项目中,由于 node 的版本比较高,因此 node-sass 的版本一般也是比较高
     的,但有时却因为 sass 的版本的问题,可能还需要安装 sass,命令为:npm i sass

// sass 的报错信息为:
在这里插入图片描述

4、小结:

其一、哪里有不对或不合适的地方,还请大佬们多多指点和交流!
其二、若有转发或引用本文章内容,请注明本博客地址https://blog.csdn.net/weixin_43405300,创作不易,且行且珍惜!
其三、有兴趣的话,可以多多关注这个专栏(Vue(Vue2+Vue3)面试必备专栏):https://blog.csdn.net/weixin_43405300/category_11525646.html?spm=1001.2014.3001.5482

猜你喜欢

转载自blog.csdn.net/weixin_43405300/article/details/131717884