警告:运行“compass:server”(compass)任务

30
D:\Projects\mallspk>grunt serve
Running "serve" task

Running "clean:server" (clean) task
>> 0 paths cleaned.

Running "wiredep:app" (wiredep) task

Running "wiredep:test" (wiredep) task

Running "wiredep:sass" (wiredep) task

Running "concurrent:server" (concurrent) task
    Warning: Running "compass:server" (compass) task
Warning: Command failed: 'compass.bat' is not recognized as an internal or exter
nal command,
    operable program or batch file.
     Use --force to continue.

我已经安装了 Yo angular 并运行了以下命令:

npm install grunt --save-dev
npm install -g grunt-contrib-compass 
npm install -g compass
npm install
bower install
npm install  grunt-google-cdn

当我运行命令grunt serve时,出现了以下错误。我已经安装了最新的Node和npm,并安装了最新的Grunt和Yo。

8个回答

36

我在@squiroid上安装了Ruby。我忘记运行gem install compass。这对我有用。


1
这不是感谢回答,而是我问题的解决方案。我已经回答了我的问题,所以任何遇到这个问题的人都会找到正确的解决方案。 - user4069483
我必须先运行 sudo apt-get install ruby-compass - DDS

16

我在ubuntu上遇到了同样的问题,我用以下方法解决了这个问题:

  1. sudo apt-get install ruby
  2. sudo apt-get install ruby-compass
  3. sudo gem install compass

之后,运行 grunt serve 就可以了。


我已经安装了Ruby,并安装了Compass gem,但由于某些原因,我仍然需要按照这里的建议安装apt-get ruby-compass。谢谢! - Kyle Baker
2
我使用这个解决方案,需要使用apt安装ruby-compass,否则在Ubuntu上无法工作。谢谢! - anibal

9

我曾经遇到过同样的问题,后来在我的桌面电脑上安装了compass gem就解决了。

如果你使用的是OS X或Linux系统,那么你很可能已经安装了Ruby;可以在终端中输入ruby -v进行测试。当你确认已经安装了Ruby之后,运行gem update --system && gem install compass命令来安装Compass和Sass。

对于Windows用户,可以先下载Ruby,然后再安装Compass。

希望这能帮到你 :)


如果你使用的是Ubuntu系统,那么你应该避免使用系统中已安装的Ruby版本。请参考:https://dev59.com/_loU5IYBdhLWcg3wM00H#37956249 - Kyle Baker

7

我搜索了很久,直到最终找到了解决这个问题的答案。
在我的情况下,是当我正在使用yeomen创建一个新的angularjs应用程序时发生的。

这个答案是针对Windows用户的

步骤1:安装ruby http://rubyinstaller.org/downloads/

步骤2:下载rubygems 链接:https://rubygems.org/rubygems/rubygems-2.6.8.zip

步骤3:解压rubygems-2.6.8.zip文件

步骤4:打开powershell(终端/命令行),并进入rubygems-2.6.8文件夹路径。(例如:c:\folder\folder)

步骤5:在powershell终端中运行以下命令:

> ruby setup.rb

> gem install compass

祝你愉快!


谢谢,这太好了。坏的一部分是我甚至没有使用 Ruby。我是用 NET Web API 和 Angular 前端。 - Randy R
我也是。相信我,它有效。Ruby 的作用是让 CSS 预编译器 Sass 或 Less 可以运行。至少在本地运行时是这样的。 - Mbuso Mkhize
工作得非常完美。尽管我必须使用Ruby打开命令提示符。知道一种用Ruby打开ConEmu的方法吗?因为Ruby没有在我的系统上全局安装。所以我不能随处使用它。不知道为什么。 - Uzumaki Naruto

5

我遇到了同样的问题

使用sass选项的"yo angular"将使用compass,而compass是一个ruby gem。

安装ruby和compass。

在Windows系统中,我们还需要设置ruby的路径。将ruby/bin添加到路径中。

然后 "grunt serve" 就可以工作了!


谢谢您。我读到的其他所有内容都只是说要更新Compass,没有提到需要将Ruby添加到路径中的其他Windows特定解决方案。 - Mike.C.Ford
将 .RB 和 .RBW 添加到环境变量值列表作为 %PATHEXT%;.RB;.RBW,然后单击确定。请查看 http://www.tutorialspoint.com/ruby/ruby_installation_windows.htm。 - Afshin Ghazi

1

我也遇到了这些问题,我通过将源映射设置为false找到了一个临时解决办法。

server: {
        options: {
          sourcemap: false <--
        }
      }

之后,它就像魅力一样工作。

1

grunt-contrib-compass文档中可以看到:

"这个任务要求你安装Ruby、Sass和Compass >=1.0.1" 和 "当你确认已经安装了Ruby后,运行gem update --system && gem install compass来安装Compass和Sass。"

我按照这些说明操作后,修复了警告。


0
如果你在使用node+express+Angular时对Ruby有同样奇怪的感觉,可以运行“yo angular xyz”,但是请使用gulp代替grunt。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接