Grunt - 没有找到任务“组装”

时间:2016-01-15 11:51:07

标签: gruntjs assemble

Haven已经玩了好几个小时了

package.json

{
  "name": "compile-tests",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "grunt": "^0.4.5",
    "assemble": "^0.7.3"
  }
}

Gruntfile.js

module.exports = function(grunt) {
    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        assemble: {
            options: {
                flatten: true,
                layout: "../templates/1.hbs"
            },
            pages: {
                files: {
                    '../dist' : ['../pages/*.hbs']
                }
            }

        }
    });
    grunt.loadNpmTasks('assemble');
    grunt.registerTask('default', ['assemble']);
};

尝试删除并重新安装所有模块几次。并尝试了不同的版本,有趣的是,本文中提到的版本http://blog.parkji.co.uk/2013/07/06/building-a-static-site-using-grunt-and-assemble.html似乎有效,但后来我遇到了其他问题,因为这些版本已经过时了。

错误

$ Grunt
>> Local Npm module "assemble" not found. Is it installed?
Warning: Task "assemble" not found. Used --force, continuing.

1 个答案:

答案 0 :(得分:11)

我只需要使用grunt-assemble

$ npm install grunt-assemble --save-dev

并在Gruntfile.js中调整此行

grunt.loadNpmTasks('grunt-assemble');