英文:
Sass is not found after creating a new Vue app and adding lang="sass" to some styles
问题
这是当前安装的Sass版本:
> sass --version
1.62.1 编译版本 dart2js 2.19.6
然而,如果我使用 npm run dev
启动Vue应用并打开应用程序URL,我会得到以下错误消息:
预处理器依赖 "sass" 未找到。您是否安装了它?
18:47:19 [vite] 内部服务器错误:预处理器依赖 "sass" 未找到。您是否安装了它?
插件:vite:css
在浏览器中,我看到以下消息:
[plugin:vite:css] 预处理器依赖 "sass" 未找到。您是否安装了它?
但是Sass运行正常。如何在Vue中成功启用Sass?该应用程序是使用 npm init vue@latest
创建的。我曾经安装了node-sass,但已将其删除。
英文:
This is the current Sass version installed:
> sass --version
1.62.1 compiled with dart2js 2.19.6
Yet if I start the vue application with npm run dev
and open the app url I get
Preprocessor dependency "sass" not found. Did you install it?
18:47:19 [vite] Internal server error: Preprocessor dependency "sass" not found. Did you install it?
Plugin: vite:css
In the browser I see:
[plugin:vite:css] Preprocessor dependency "sass" not found. Did you install it?
But Sass runs just fine. How do I enable Sass in Vue successfully? The app was created with npm init vue@latest
.
I used to have node-sass installed but removed it
答案1
得分: 1
你必须将SASS与编译器链接,为此需要在项目中添加sass-loader。
npm i -D sass-loader
我个人更喜欢将SASS安装为本地依赖,因为这样你可以更好地控制这个库的版本,尤其是对于“旧”项目(今天的项目,可能在5年或更长时间内存在)。
英文:
You must link SASS with the compiler, to do this you need to add sass-loader in your project.
npm i -D sass-loader
Personally I prefer to install SASS as a local dependency, because you'll have more control over the version of this library, specially for "old" projects (today projects, old in maybe 5 or more years).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论