如何解决VS Code 不允许我使用 sass --watch 编译 sass
我正在尝试使用终端编译 sass。我已经安装了 node.js,并且在使用 Live Sass 时没有任何问题,但是,每次我尝试编译我的 sass 时,我都会得到这个:
sass : The term 'sass' is not recognized as the name of a cmdlet,function,script file,or operable program.
Check the spelling of the name,or if a path was included,verify that the path is correct and try again.
At line:1 char:1
+ sass -watch scss:css
+ ~~~~
+ CategoryInfo : ObjectNotFound: (sass:String) [],CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
我正在尝试使用 @use
并且我知道 Live Sass 编译器不会让我这样做。
有什么我做错了吗?或者我需要安装的其他东西?
哦,我已经使用 npm install sass
安装了 sass。
解决方法
您有两个选择:
-
尝试全局安装
npm install -g node-sass
-
添加这个 package.json 文件
"devDependencies": { "node-sass": "4.5.0" },"scripts" : { "node-sass": "node-sass --output-style compressed -o dist/css src/scss" }
之后,运行:
npm i;npm run node-sass;
注意:有几种方法可以在 VS Code 中使用 SASS。但请确保使用与 Dart SASS
一起运行的最实际版本。要通过 NPM 安装,这里有一些信息:
这里有一些关于通过安装 VS Code 扩展来使用 SASS 的信息,这可能会让使用它更舒服一些:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。