yeoman运行grunt serve 提示错误

今天在使用 yeoman 的时候,当我运行 grunt serve 命令的时候,出现如下提示:

1、Error: Cannot find module 'load-grunt-tasks'

$ grunt serve
Loading "Gruntfile.js" tasks...ERROR
>> Error: Cannot find module 'load-grunt-tasks'
Warning: Task "serve" not found. Use --force to continue.

Aborted due to warnings.

  该错误是因为没有安装 load-grunt-tasks 插件,我们运行如下命令将,所有该项目依赖的所欲node插件,全部安装,命令如下:

# $ sudo npm install     #for mac
$ npm install

  该命令会将 package.js 中依赖的所有node插件全部安装。

参考文档:http://stackoverflow.com/questions/18114666/grunt-fatal-error-unable-to-find-local-grunt-in-yeoman

 

 

2、Warning: Running "compass:server" (compass) task

$ 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 --version
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'compass' (>= 0) among 45 total gem(s) (Gem::LoadError)
    	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
    	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
    	from /usr/bin/compass:22:in `<main>'
     Use --force to continue.
    
    Aborted due to warnings.
    
    
    Execution Time (2015-04-12 05:32:54 UTC)
    loading tasks    5ms  ▇▇▇ 5%
    compass:server  85ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 93%
    Total 91ms Use --force to continue.
        
        Aborted due to warnings.
    

Execution Time (2015-04-12 05:32:50 UTC)
wiredep:app        134ms  ▇▇▇ 4%
concurrent:server     3s  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 95%
Total 3.2s

  网上搜了一堆blog,最后发现是未安装 compass ,因为我用 yeoman 构建项目的时候,选了使用 sass ,而在yeoman中使用sass则又需要安装 compass (直接使用sass是不需要的)。

参考文档:http://stackoverflow.com/questions/21865609/grunt-need-compass-installed-in-system-path-warning 

compass是基于 ruby 的,因此在安装 compass 前,你先需要确定,你的电脑已经安装了 ruby 。

现在我再来安装 compass:

$ gem install compass

  

安装好 compass 后,在运行 grunt serve 命令,就会自动打开 http://localhost:9000 。

你就会看到 yeoman 构建工具,创建的默认页面。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值