我的解决方案:
执行以下脚本:
npm uninstall sass-loader node-sass
npm install sass-loader@8.0.2 sass@1.26.5 --save-dev
不要安装node-sass,安装sass就可以了,package.json如下
{
"name": "vue3.0-demo-1",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
},
"dependencies": {
"core-js": "^3.6.5",
"joi": "^17.4.2",
"vue": "^2.6.11"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^7.15.0",
// 这两个是重点:sass、sass-loader
"sass": "^1.26.5",
"sass-loader": "^8.0.2",
"vue-template-compiler": "^2.6.11"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}