问题描述
我正在尝试使用终端编译 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 的信息,这可能会让使用它更舒服一些: