SCSS 文件不再编译

问题描述 投票:0回答:4

直到昨天 Sass 都工作得很好,现在,Sass 不再编译我的 SCSS 文件了。

这是我迄今为止尝试过的方法,但没有解决问题:

  1. 卸载当前版本的 Sass 并安装旧版本
  2. 安装最新版本的 Sass
  3. 卸载 Ruby 并安装最新版本
  4. 重新启动我的机器

技术信息:

  • Win7 64b
  • Sass 版本 3.2.3
  • 指南针版本0.12.2
  • 使用的CMD命令:
    sass --watch scss:css --style compact --compass --debug-info
  • 编辑器:Sublime Text 2

其他信息:

发生的奇怪的事情是,如果我在

.scss
文件中写了一些不正确的内容,例如像
#f00a
这样的颜色的四位十六进制值,然后运行
--watch
,Sass 会立即检测到问题,并重写
 .css
有错误的文件。

这意味着 Sass 在某种程度上正在部分工作。

输入所有

--watch
命令后,Sass 通常会启动:
>>> Sass is watching for changes. Press Ctrl-C to stop.

但是,当我保存

.scss
文件时,Sass 不再编译。它就留在那里。

还有其他人遇到过 Sass 停止编译的问题吗?

事情是,现在我无法再处理我的项目了,因为无法再创建 CSS 文件,因此非常感谢对此的任何帮助。

谢谢。

--更新

我还是无法编译。

但是,停止

--watch
后,我的 CMD 中会出现一个巨大的项目列表。在我家里的 PC Sass 工作正常,当我停止
--watch
时,我没有得到任何像这样的列表或任何东西:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

c:\...\www>sass --watch scss:css --style compact --compass --debug-info --trace
>>> Sass is watching for changes. Press Ctrl-C to stop.

C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/util/multibyte_string_sc anner.rb:36:in `scan': Interrupt from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/util/multibyte_string_scanner.rb:36:in `scan'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/scss/parser.rb:1142:in `tok'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/scss/parser.rb:865:in `value!'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/scss/parser.rb:845:in `declaration'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/scss/parser.rb:568:in `block in declaration_or_ruleset'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/scss/parser.rb:1090:in `block in catch_error'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/scss/parser.rb:1090:in `catch'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/scss/parser.rb:1090:in `catch_error'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/scss/parser.rb:567:in `declaration_or_ruleset'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/scss/parser.rb:540:in `block_child'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/scss/parser.rb:532:in `block_contents'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/scss/parser.rb:521:in `block'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/scss/parser.rb:515:in `ruleset'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/scss/parser.rb:539:in `block_child'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/scss/parser.rb:532:in `block_contents'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/scss/parser.rb:70:in `stylesheet'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/scss/parser.rb:27:in `parse'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/engine.rb:342:in `_to_tree'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/engine.rb:315:in `_render'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/engine.rb:262:in `render'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/plugin/compiler.rb:341:in `update_stylesheet'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/plugin/compiler.rb:203:in `block in update_stylesheets'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/plugin/compiler.rb:201:in `each'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/plugin/compiler.rb:201:in `update_stylesheets'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/plugin/compiler.rb:235:in `watch'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/plugin.rb:107:in `method_missing'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/exec.rb:444:in `watch_or_update'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/exec.rb:307:in `process_result'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/exec.rb:41:in `parse'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/lib/sass/exec.rb:21:in `parse!'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.3/bin/sass:8:in `<top(required)>'
    from C:/Ruby193/bin/sass:23:in `load'
    from C:/Ruby193/bin/sass:23:in `<main>'
Terminate batch job (Y/N)?

CSS解析器有问题还是什么?

sass
4个回答
20
投票

我遇到了类似的问题,但是使用 Sass 和 Compass。幸运的是,我设法通过运行

compass clean
命令解决了这个问题,该命令删除了
.sass-cache
文件和已编译的 .css 文件。然后再次运行
compass --watch
命令即可。希望这可以帮助别人。


8
投票

诚然,这对我来说非常愚蠢,但这确实是我在偶然发现这个 stackoverflow 问答时遇到的问题。

这是我非常简单的问题的简单答案:

确保您在主 style.scss 文件中 @importing 该文件。

显然不是您非常复杂问题的答案,但它可能会帮助一些与我处境相似的新手!


5
投票

我发现了问题:我的 /scss 文件夹中的 .scss 文件之一导致 Sass 停止编译。

“有问题的”文件是项目主 .scss 文件的旧副本,但是当我将该旧版本与最新版本进行比较时,我只看到底部的属性、值和媒体查询方面的一些差异代码。

除此之外,“有问题”和“正确/工作”文件几乎 98% 完全相同。

在 GitHub 中的项目问题列表中阅读更详细的答案:https://github.com/nex3/sass/issues/362#issuecomment-11255429


0
投票

对于您的子 scss 文件的每次更改,您都应该保存 (ctrl+s) 您的主 scss 文件。

© www.soinside.com 2019 - 2024. All rights reserved.