yeoman運行grunt serve 提示錯誤

今天在使用 yeoman 的時候,當我運行 grunt serve 命令的時候,出現以下提示:node

一、Error: Cannot find module 'load-grunt-tasks'npm

$ 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插件,所有安裝,命令以下:sass

# $ sudo npm install     #for mac
$ npm install

  該命令會將 package.js 中依賴的全部node插件所有安裝。ruby

參考文檔:http://stackoverflow.com/questions/18114666/grunt-fatal-error-unable-to-find-local-grunt-in-yeomanapp

 

 

二、Warning: Running "compass:server" (compass) taskgrunt

$ 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 。server

如今我再來安裝 compass:blog

$ gem install compass

  

安裝好 compass 後,在運行 grunt serve 命令,就會自動打開 http://localhost:9000 。

你就會看到 yeoman 構建工具,建立的默認頁面。

相關文章
相關標籤/搜索