安装后 Sass 和 Compass 出现奇怪的 CSS 错误

Posted

技术标签:

【中文标题】安装后 Sass 和 Compass 出现奇怪的 CSS 错误【英文标题】:Sass and Compass weird css errors after install 【发布时间】:2013-03-31 07:56:26 【问题描述】:

我安装了 compass,但无法正确编译为 css。我不知道是什么原因造成的。即使你 *** 要求我写更多。

    安装侦察兵。 创建了简单的 css 和 html 文件。 试图编译css文件。 出错了。 在谷歌上找不到答案。

我的 CSS:

body 
    background: black;

输出:

/*
Syntax error: Invalid CSS after "black": expected expression (e.g. 1px, bold), was ";"
        on line 2 of C:/Users/Andrej/Documents/My Dropbox/Web Projects/First good website/sass/main.sass

1: C:/Users/Andrej/Documents/My Dropbox/Web Projects/First good website/sass/main.sass

Backtrace:
C:/Users/Andrej/Documents/My Dropbox/Web Projects/First good website/sass/main.sass:2
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/scss/parser.rb:1129:in `expected'
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/script/lexer.rb:199:in `expected!'
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/script/parser.rb:486:in `assert_done'
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/script/parser.rb:50:in `parse'
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/script/parser.rb:166:in `parse'
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/script.rb:31:in `parse'
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/engine.rb:875:in `parse_script'
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/engine.rb:608:in `parse_property'
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/engine.rb:597:in `parse_property_or_rule'
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/engine.rb:578:in `parse_line'
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/engine.rb:471:in `build_tree'
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/engine.rb:490:in `append_children'
org/jruby/RubyArray.java:1603:in `each'
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/engine.rb:489:in `append_children'
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/engine.rb:480:in `build_tree'
org/jruby/RubyArray.java:1603:in `each'
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/engine.rb:473:in `build_tree'
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/engine.rb:490:in `append_children'
org/jruby/RubyArray.java:1603:in `each'
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/engine.rb:489:in `append_children'
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/engine.rb:345:in `_to_tree'
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/engine.rb:315:in `_render'
d:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/engine.rb:262:in `render'
d:/program files (x86)/scout/vendor/gems/gems/compass-0.12.2/lib/compass/compiler.rb:140:in `compile'
d:/program files (x86)/scout/vendor/gems/gems/compass-0.12.2/lib/compass/compiler.rb:126:in `timed'
d:/program files (x86)/scout/vendor/gems/gems/compass-0.12.2/lib/compass/compiler.rb:139:in `compile'
d:/program files (x86)/scout/vendor/gems/gems/compass-0.12.2/lib/compass/logger.rb:45:in `red'
d:/program files (x86)/scout/vendor/gems/gems/compass-0.12.2/lib/compass/compiler.rb:138:in `compile'
d:/program files (x86)/scout/vendor/gems/gems/compass-0.12.2/lib/compass/compiler.rb:118:in `compile_if_required'
d:/program files (x86)/scout/vendor/gems/gems/compass-0.12.2/lib/compass/compiler.rb:103:in `run'
org/jruby/RubyArray.java:1603:in `each'
d:/program files (x86)/scout/vendor/gems/gems/compass-0.12.2/lib/compass/compiler.rb:101:in `run'
d:/program files (x86)/scout/vendor/gems/gems/compass-0.12.2/lib/compass/compiler.rb:126:in `timed'
d:/program files (x86)/scout/vendor/gems/gems/compass-0.12.2/lib/compass/compiler.rb:100:in `run'
d:/program files (x86)/scout/vendor/gems/gems/compass-0.12.2/lib/compass/commands/watch_project.rb:147:in `recompile'
org/jruby/RubyMethod.java:133:in `call'
org/jruby/RubyProc.java:268:in `call'
org/jruby/RubyProc.java:228:in `call'
d:/program files (x86)/scout/vendor/gems/gems/fssm-0.2.9/lib/fssm/path.rb:73:in `run_callback'
d:/program files (x86)/scout/vendor/gems/gems/fssm-0.2.9/lib/fssm/path.rb:55:in `callback_action'
d:/program files (x86)/scout/vendor/gems/gems/fssm-0.2.9/lib/fssm/path.rb:35:in `update'
d:/program files (x86)/scout/vendor/gems/gems/fssm-0.2.9/lib/fssm/state/directory.rb:39:in `modified'
org/jruby/RubyArray.java:1603:in `each'
d:/program files (x86)/scout/vendor/gems/gems/fssm-0.2.9/lib/fssm/state/directory.rb:37:in `modified'
d:/program files (x86)/scout/vendor/gems/gems/fssm-0.2.9/lib/fssm/state/directory.rb:18:in `refresh'
d:/program files (x86)/scout/vendor/gems/gems/fssm-0.2.9/lib/fssm/backends/polling.rb:17:in `run'
org/jruby/RubyArray.java:1603:in `each'
d:/program files (x86)/scout/vendor/gems/gems/fssm-0.2.9/lib/fssm/backends/polling.rb:17:in `run'
org/jruby/RubyKernel.java:1419:in `loop'
d:/program files (x86)/scout/vendor/gems/gems/fssm-0.2.9/lib/fssm/backends/polling.rb:15:in `run'
d:/program files (x86)/scout/vendor/gems/gems/fssm-0.2.9/lib/fssm/monitor.rb:26:in `run'
d:/program files (x86)/scout/vendor/gems/gems/fssm-0.2.9/lib/fssm.rb:70:in `monitor'
d:/program files (x86)/scout/vendor/gems/gems/compass-0.12.2/lib/compass/commands/watch_project.rb:87:in `perform'
d:/program files (x86)/scout/vendor/gems/gems/compass-0.12.2/lib/compass/commands/base.rb:18:in `execute'
d:/program files (x86)/scout/vendor/gems/gems/compass-0.12.2/lib/compass/commands/project_base.rb:19:in `execute'
d:/program files (x86)/scout/vendor/gems/gems/compass-0.12.2/lib/compass/exec/sub_command_ui.rb:43:in `perform!'
d:/program files (x86)/scout/vendor/gems/gems/compass-0.12.2/lib/compass/exec/sub_command_ui.rb:15:in `run!'
d:\program files (x86)\scout\bin\compass:12:in `(root)'
*/
body:before 
  white-space: pre;
  font-family: monospace;
  content: "Syntax error: Invalid CSS after \"black\": expected expression (e.g. 1px, bold), was \";\"\A         on line 2 of C:/Users/Andrej/Documents/My Dropbox/Web Projects/First good website/sass/main.sass\A \A 1: C:/Users/Andrej/Documents/My Dropbox/Web Projects/First good website/sass/main.sass"; 

请提前帮助并感谢您的回答。

【问题讨论】:

【参考方案1】:

问题可能是您正在编写一个.sass 文件,您可能想要编写一个.scss 文件。 .sass 是旧版语法,与常规 CSS 不兼容。

【讨论】:

成功了!太好了:)感谢您的快速回答。当***让我接受时我会接受它。 致 Nathan Bouscal:“.sass 与常规 CSS 不兼容”您可能表示 CSS 在语法上是 SCSS 的子集。 SASS 较旧,不能仅通过重命名将.css 转换为.sass,但完全支持和兼容缩进的 SASS 语法。我更喜欢 SASS,因为它更干净、更易读、写起来也更快。 SCSS 只是增加了很多噪音:d.pr/i/7sbD+(尽管 SCSS 确实允许一些 SASS 无法实现的良好代码对齐)。 @lolmaus 是的,这就是我的意思,我可能可以更好地表述它:.sass 不是 CSS 的扩展。

以上是关于安装后 Sass 和 Compass 出现奇怪的 CSS 错误的主要内容,如果未能解决你的问题,请参考以下文章

邂逅Sass和Compass之Compass篇

sass,compass让开发效率飞起

安装 RVM 后无法加载 Sass / Compass,与 Symfony2 中的 Assetic 一起使用

由于版本冲突,无法安装 sass + compass + susy

win7下安装Sass和compass

关于Sass与Compass的一些笔记