警告:flatten 不是函数使用 --force 继续
Warning: flatten is not a function Use --force to continue
我对 g运行t 有一个非常奇怪的错误。由于某种原因,在我们的 CI 系统中运行一段时间后,此任务开始失败。可能有人面临同样的问题?
当我 运行 g运行t assemble:site 它输出:
Running "assemble:site" (assemble) task
Warning: flatten is not a function Use --force to continue.
如何修复这个错误?任务中的一些配置问题?
Gruntfile.jsassemble任务部分
module.exports = function(grunt) {
grunt.initConfig({
//other tasks
assemble: {
options: {
production: true,
ext: '.html',
data: 'src/data/*.json',
assets: 'dist/assets',
helpers: 'src/helpers/*-helper.js',
layoutdir: 'src/templates/layouts',
partials: ['src/templates/partials/*.hbs']
},
site: {
options: {
layout: 'default.hbs'
},
files: [{
expand: true,
cwd: 'src/templates/pages',
src: ['*.hbs'],
dest: 'dist/'
}]
}
},
//other tasks
});
//other loadNpmTasks
grunt.loadNpmTasks('grunt-assemble');
//other registerTask
grunt.registerTask('build', [
'concat:bootstrap',
'concat:js',
'uglify:js',
'copy:js',
'assemble',
'prettify',
'sprite',
'svgmin',
'sass',
'postcss',
'copy:gfx',
'pngmin'
]);
}
Package.json 文件:
{
"name": "html-prototype",
"version": "1.0.0",
"description": "HTML prototype",
"devDependencies": {
"autoprefixer": "^6.7.2",
"grunt": "^1.0.0",
"grunt-assemble": "^0.6.3",
"grunt-autoprefixer": "^3.0.4",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-uglify": "^2.0.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-newer": "^1.1.0",
"grunt-pngmin": "^1.0.2",
"grunt-postcss": "^0.8.0",
"grunt-prettify": "0.4.0",
"grunt-sass": "^2.0.0",
"grunt-string-replace": "^1.3.1",
"grunt-svg-sprite": "1.4.0",
"grunt-svgmin": "^4.0.0",
"node-sass": "~4.5.0",
"postcss-placehold": "^1.2.0",
"postcss-svg": "^1.0.6",
"svg-sprite": "1.4.0"
},
"dependencies": {
"digits": "~0.2.0"
},
"scripts": {
"grunt-build": "grunt build"
}
}
包本身存在一些问题。 More info here。
我对 g运行t 有一个非常奇怪的错误。由于某种原因,在我们的 CI 系统中运行一段时间后,此任务开始失败。可能有人面临同样的问题?
当我 运行 g运行t assemble:site 它输出:
Running "assemble:site" (assemble) task
Warning: flatten is not a function Use --force to continue.
如何修复这个错误?任务中的一些配置问题?
Gruntfile.jsassemble任务部分
module.exports = function(grunt) {
grunt.initConfig({
//other tasks
assemble: {
options: {
production: true,
ext: '.html',
data: 'src/data/*.json',
assets: 'dist/assets',
helpers: 'src/helpers/*-helper.js',
layoutdir: 'src/templates/layouts',
partials: ['src/templates/partials/*.hbs']
},
site: {
options: {
layout: 'default.hbs'
},
files: [{
expand: true,
cwd: 'src/templates/pages',
src: ['*.hbs'],
dest: 'dist/'
}]
}
},
//other tasks
});
//other loadNpmTasks
grunt.loadNpmTasks('grunt-assemble');
//other registerTask
grunt.registerTask('build', [
'concat:bootstrap',
'concat:js',
'uglify:js',
'copy:js',
'assemble',
'prettify',
'sprite',
'svgmin',
'sass',
'postcss',
'copy:gfx',
'pngmin'
]);
}
Package.json 文件:
{
"name": "html-prototype",
"version": "1.0.0",
"description": "HTML prototype",
"devDependencies": {
"autoprefixer": "^6.7.2",
"grunt": "^1.0.0",
"grunt-assemble": "^0.6.3",
"grunt-autoprefixer": "^3.0.4",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-uglify": "^2.0.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-newer": "^1.1.0",
"grunt-pngmin": "^1.0.2",
"grunt-postcss": "^0.8.0",
"grunt-prettify": "0.4.0",
"grunt-sass": "^2.0.0",
"grunt-string-replace": "^1.3.1",
"grunt-svg-sprite": "1.4.0",
"grunt-svgmin": "^4.0.0",
"node-sass": "~4.5.0",
"postcss-placehold": "^1.2.0",
"postcss-svg": "^1.0.6",
"svg-sprite": "1.4.0"
},
"dependencies": {
"digits": "~0.2.0"
},
"scripts": {
"grunt-build": "grunt build"
}
}
包本身存在一些问题。 More info here。