Yeoman定制发电机

时间:2014-04-05 19:26:15

标签: gruntjs yeoman

我在为Yeoman创建自定义生成器时遇到问题。

生成的文件夹和文件的结构很好。

如果我运行生成器,那么没有错误,所有文件都是正确的

问题是创建gruntfile.js。

如果我运行grunt服务器,我会收到错误 - 警告:任务"表达"未找到。使用--force继续。

Gruntfile.js是我在这里和那里找到的一些混合物,所以它可以是任何东西。

有没有人知道任何解释如何执行此操作的教程,或者任何人都可以看到为什么这个grunt文件无法正常工作。

    // Gruntfile with the configuration of grunt-express and grunt-open. No livereload yet!
    module.exports = function (grunt) {

      'use strict';

      // Load Grunt tasks declared in the package.json file
      //require('load-grunt-tasks')(grunt);

      // Configure Grunt 
      grunt.initConfig({

        // grunt-express serves the files from the folders listed in `bases`
        // on specified `port` and `hostname`
        express: {
          all: {
            options: {
              port: 9000,
              hostname: '0.0.0.0',
              bases: [__dirname],
              livereload: true
            }
          }
        },

        // grunt-watch monitors the projects files
        watch: {
          all: {

            files: ['index.html', 'css/**/*.css', 'js/**/*.js'],
            options: {
              livereload: true
            }
          }
        },

        // grunt-open will open your browser at the project's URL
        open: {
          all: {
            // Gets the port from the connect configuration
            path: 'http://localhost:<%= express.all.options.port%>'
          }
        }
      });

      // Creates the `server` task
      grunt.registerTask('serve', [
        'express',
        'open',
        'watch'
      ]);
    };

1 个答案:

答案 0 :(得分:0)

我认为您需要从// require('load-grunt-tasks')(grunt)中删除斜杠,以便它将在package.json中加载依赖项

相关问题