Grunt需要安装在系统PATH中的Compass警告

29

我想要在我的Node项目中安装Yeoman、Grunt和Bower。

我使用Nodeclipse插件在Eclipse中创建了一个Node项目,并在cmd中导航到项目文件夹(该文件夹位于H:\Eclipse Workspace\YoTest),然后输入以下命令:

npm install yo -g

npm install generator-webapp -g

yo webapp

选择了:Sass(使用Compass),在命令行中输入:

然后输入:

grunt serve
运行Web应用程序时,我收到以下错误信息:
Done, without errors.
    Warning: Running "compass:server" (compass) task
Warnin: You need to have Ruby and Compass installed and in your system PATH for
 this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass
Use --force to continue.

Aborted due to warnings. Use --force to continue.

    Aborted due to warnings.

我该如何修复这个问题,以便使用grunt运行我的节点项目?

PS:我不确定这是否与问题有关,但我在package.json的1-27行中还会遇到以下错误:

Multiple markers at this line
    - strings must use singlequote
    - strings must use singlequote

这是我的 package.json 文件

{
  "name": "yotest2",
  "version": "0.0.0",
  "dependencies": {},
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-contrib-copy": "~0.4.1",
    "grunt-contrib-concat": "~0.3.0",
    "grunt-contrib-uglify": "~0.2.0",
    "grunt-contrib-compass": "~0.7.0",
    "grunt-contrib-jshint": "~0.7.0",
    "grunt-contrib-cssmin": "~0.7.0",
    "grunt-contrib-connect": "~0.5.0",
    "grunt-contrib-clean": "~0.5.0",
    "grunt-contrib-htmlmin": "~0.1.3",
    "grunt-bower-install": "~0.7.0",
    "grunt-contrib-imagemin": "~0.2.0",
    "grunt-contrib-watch": "~0.5.2",
    "grunt-rev": "~0.1.0",
    "grunt-autoprefixer": "~0.5.0",
    "grunt-usemin": "~2.0.0",
    "grunt-mocha": "~0.4.0",
    "grunt-modernizr": "~0.4.0",
    "grunt-newer": "~0.6.0",
    "grunt-svgmin": "~0.2.0",
    "grunt-concurrent": "~0.4.0",
    "load-grunt-tasks": "~0.2.0",
    "time-grunt": "~0.2.0",
    "jshint-stylish": "~0.1.3"
  },
  "engines": {
    "node": ">=0.8.0"
  }
}

我在使用Windows操作系统。

5个回答

38

这个警告似乎已经说明了一切。

  1. 如果你使用的是OS X或者Linux操作系统,你很可能已经安装好了Ruby;在终端中输入 ruby -v 来检查。当你确认安装了Ruby后,运行 gem update --system && gem install compass 来安装Compass和Sass。

  2. 如果还是有问题,可以按照https://github.com/gruntjs/grunt-contrib-compass上的说明安装grunt-contrib-compass包。


6
我使用的是Windows系统,已经安装了Ruby、Compass和Sass。我也按照grunt-contrib-compass的教程操作,但仍然无法让它正常工作。唯一能让它工作的方法是使用"grunt serve --force"命令,但这样会导致CSS等文件无法加载。 - user2539369
1
+1 感谢Eric,- @Rockyy,我刚才不得不从Windows机器上运行gem update --system && gem install compass来完成这个。 - Rob Sedgwick
您没有对 /Library/Ruby/Gems/1.8 目录的写入权限。我遇到了上述错误。使用 sudo 命令会卡住。 - Ankit Tanna
为什么这被标记为答案?问题明确说明他正在使用Windows。除非微软现在将Windows称为“OS X”,否则我认为你必须在谈论其他一些果味操作系统。 - Adam Plocher
在Windows上,请确保Ruby和Compass已安装并在系统PATH中。我不得不重新启动IDE以获取更新的环境。 - Vadzim

3

当我运行gulp watch时,这个错误信息困扰了我好几个小时。尽管我安装、卸载和重启了多次,但错误信息仍然显示出来。

最终我通过卸载所有的包来解决问题:

sudo gem uninstall bundler bundle compass sass compass-core compass-import-once

只安装捆绑包。
sudo gem install bundle bundler

然后运行这个神奇的命令,它会安装我需要的一切:

$ bundle
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/..
Installing sass 3.4.9
Installing sassy-maps 0.4.0
Installing breakpoint 2.5.0
Installing hitimes 1.2.2
Installing timers 4.0.1
Installing celluloid 0.16.0
Using chunky_png 1.3.3
Using multi_json 1.10.1
Installing compass-core 1.0.1
Using compass-import-once 1.0.5
Using rb-fsevent 0.9.4
Using ffi 1.9.6
Using rb-inotify 0.9.5
Installing compass 1.0.1
Installing json 1.8.1
Installing listen 2.8.3
Installing thor 0.19.1
Installing fontcustom 1.3.7
Installing modular-scale 2.0.5
Installing normalize-scss 3.0.2
Installing sass-css-importer 1.0.0.beta.0
Installing sassy-buttons 0.2.6
Installing susy 2.1.3
Using bundler 1.8.0
Bundle complete! 9 Gemfile dependencies, 24 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from compass:
    Compass is charityware. If you love it, please donate on our behalf at http://umdf.org/compass Thanks!
Post-install message from fontcustom:
>> Thanks for installing Font Custom! Please ensure that fontforge is installed before compiling any icons. Visit <http://fontcustom.com> for instructions.

现在,不要问我为什么,但所有的都能正常工作 :-)
希望这能帮助到任何需要的人,我真的在这个问题上挣扎了很久...

0
只需要在控制台上写入 -> (或sudo) gem install compass,因为npm命令不会做任何事情。

它被卡住了,什么也动不了。 :( 你没有将文件写入 /Library/Ruby/Gems/1.8 目录的权限。 - Ankit Tanna

0

对于 Mac OS X 10.10(Yosemite)

搜索已安装的 Ruby 版本 ruby -v。 如果存在, 使用 sudo gem update --system 更新 gems, 否则使用以下命令安装 RVM 和 Ruby: \curl -sSL https://get.rvm.io | bash -s stable --ruby

然后安装 Xcode 命令行工具 xcode-select --install。 这需要一些时间。

现在使用 sudo gem install compass 安装 Compass。 对我来说,这很顺利。


0

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