解决node-sass下载失败问题
最优解法
替换node-sass为dart-sass
npm uninstall node-sass
npm install sass -S -D
- 不兼容注意
替换 node-sass 之后有一个地方需要注意,就是它不再支持之前 sass 的那种 /deep/ 写法,需要统一改为 ::v-deep 的写法。
具体 demo:
<style lange="scss">
.a {
/deep/ {
.b {
color: red;
}
}
}
/* 修改为 而且它还是 vue 3.0 RFC 指定写法*/
.a {
::v-deep {
.b {
color: red;
}
}
}
</style>
大部分情况下都适用方法
此方法需要安装 jdk8 python2.(使用软件助手可以快速安装)
第二步可能会比较忙,长时间未响应可以尝试重新运行 (需要管理员身份运行cmd或powershell)
npm install -g node-gyp
npm install --global --production windows-build-tools
其他方法
使用cnpm
清除缓存
npm cache clear --force
cmd快速删除依赖文件
/s 是代表删除所有子目录跟其中的档案
/q 是不要它在删除档案或目录时,不再询问 Yes or No
也可以指定绝对路径执行删除:
rmdir /s /q node_modules
或
rd /s /q node_modules