Sass is not found after creating a new Vue app and adding lang="sass" to some styles

huangapple go评论72阅读模式
英文:

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).

huangapple
  • 本文由 发表于 2023年6月1日 01:01:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76375813.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定