欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

yeoman运行grunt serve 提示错误 有大用

yeoman运行grunt serve 提示错误

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

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

1
$ grunt serve
1
2
3
4
5
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插件,全部安装,命令如下:

1
2
# $ 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

1
$ grunt serve
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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:

1
$ gem install compass

  

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

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


来自   https://www.cnblogs.com/ayseeing/p/4419447.html

普通分类: