Gruntjs 配置grunt bower安装时出现问题
我对Yeoman工作流非常陌生(从今天开始使用Yeoman)。 我正在尝试安装,以便自动化资产管理过程 问题是,尽管我一直按照文档中的说明进行操作,但在尝试运行Gruntjs 配置grunt bower安装时出现问题,gruntjs,yeoman,bower,Gruntjs,Yeoman,Bower,我对Yeoman工作流非常陌生(从今天开始使用Yeoman)。 我正在尝试安装,以便自动化资产管理过程 问题是,尽管我一直按照文档中的说明进行操作,但在尝试运行grunt-bower安装时,我还是出现了错误 尝试从主目录运行此命令时,错误如下: oleg@ob:~$ !! Running "bower-install:app" (bower-install) task Verifying property bower-install.app.src exists in config...ERRO
grunt-bower安装时,我还是出现了错误
尝试从主目录运行此命令时,错误如下:
oleg@ob:~$ !!
Running "bower-install:app" (bower-install) task
Verifying property bower-install.app.src exists in config...ERROR
>> Unable to process task.
Warning: Required config property "bower-install.app.src" missing. Use --force to continue.
Aborted due to warnings.
Execution Time (2014-01-20 10:17:47 UTC)
loading tasks 3ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 25%
bower-install:app 8ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 67%
Total 12ms
'use strict';
module.exports = function (grunt) {
// Project configuration
grunt.initConfig({
// Metadata
pkg: grunt.file.readJSON('package.json'),
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= props.license %> */\n',
// Task configuration
concat: {
options: {
banner: '<%= banner %>',
stripBanners: true
},
dist: {
src: ['lib/<%= pkg.name %>.js'],
dest: 'dist/<%= pkg.name %>.js'
}
},
uglify: {
options: {
banner: '<%= banner %>'
},
dist: {
src: '<%= concat.dist.dest %>',
dest: 'dist/<%= pkg.name %>.min.js'
}
},
'bower-install': {
target: {
// Point to the files that should be updated when
// you run `grunt bower-install`
src: ['/home/oleg/index.html'],
// Optional:
// ---------
cwd: '',
ignorePath: '',
exclude: [],
fileTypes: {}
}
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
unused: true,
boss: true,
eqnull: true,
browser: true,
globals: {
jQuery: true
}
},
gruntfile: {
src: 'gruntfile.js'
},
lib_test: {
src: ['lib/**/*.js', 'test/**/*.js']
}
},
qunit: {
files: ['test/**/*.html']
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
lib_test: {
files: '<%= jshint.lib_test.src %>',
tasks: ['jshint:lib_test', 'qunit']
}
}
});
// These plugins provide necessary tasks
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-bower-install');
// Default task
grunt.registerTask('default', ['jshint', 'qunit', 'concat', 'uglify']);
};
在cding到app目录并再次运行该命令后,我得到一个不同的错误:
oleg@ob:~/app$ grunt bower-install
Loading "gruntfile.js" tasks...ERROR
>> Error: Unable to read "package.json" file (Error code: ENOENT).
Warning: Task "bower-install" not found. Use --force to continue.
Aborted due to warnings.
任何帮助都将不胜感激
我的grunfile.js(在app/dir中)如下所示:
oleg@ob:~$ !!
Running "bower-install:app" (bower-install) task
Verifying property bower-install.app.src exists in config...ERROR
>> Unable to process task.
Warning: Required config property "bower-install.app.src" missing. Use --force to continue.
Aborted due to warnings.
Execution Time (2014-01-20 10:17:47 UTC)
loading tasks 3ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 25%
bower-install:app 8ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 67%
Total 12ms
'use strict';
module.exports = function (grunt) {
// Project configuration
grunt.initConfig({
// Metadata
pkg: grunt.file.readJSON('package.json'),
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= props.license %> */\n',
// Task configuration
concat: {
options: {
banner: '<%= banner %>',
stripBanners: true
},
dist: {
src: ['lib/<%= pkg.name %>.js'],
dest: 'dist/<%= pkg.name %>.js'
}
},
uglify: {
options: {
banner: '<%= banner %>'
},
dist: {
src: '<%= concat.dist.dest %>',
dest: 'dist/<%= pkg.name %>.min.js'
}
},
'bower-install': {
target: {
// Point to the files that should be updated when
// you run `grunt bower-install`
src: ['/home/oleg/index.html'],
// Optional:
// ---------
cwd: '',
ignorePath: '',
exclude: [],
fileTypes: {}
}
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
unused: true,
boss: true,
eqnull: true,
browser: true,
globals: {
jQuery: true
}
},
gruntfile: {
src: 'gruntfile.js'
},
lib_test: {
src: ['lib/**/*.js', 'test/**/*.js']
}
},
qunit: {
files: ['test/**/*.html']
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
lib_test: {
files: '<%= jshint.lib_test.src %>',
tasks: ['jshint:lib_test', 'qunit']
}
}
});
// These plugins provide necessary tasks
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-bower-install');
// Default task
grunt.registerTask('default', ['jshint', 'qunit', 'concat', 'uglify']);
};
“严格使用”;
module.exports=函数(grunt){
//项目配置
grunt.initConfig({
//元数据
pkg:grunt.file.readJSON('package.json'),
横幅:'/*!-v-'+
“\n”+
'' +
“*版权所有(c);”+
'已授权*/\n',
//任务配置
康卡特:{
选项:{
横幅:'',
条幅:真的吗
},
地区:{
src:['lib/.js'],
dest:'dist/.js'
}
},
丑陋的:{
选项:{
横幅:“”
},
地区:{
src:“”,
dest:'dist/.min.js'
}
},
“bower安装”:{
目标:{
//指向需要更新的文件
//您运行“grunt bower安装”`
src:['/home/oleg/index.html'],
//可选:
// ---------
cwd:“”,
忽略路径:“”,
不包括:[],
文件类型:{}
}
},
jshint:{
选项:{
柯莉:是的,
Eqeq:是的,
伊梅德:没错,
拉特德:是的,
纽卡普:没错,
诺格:没错,
sub:没错,
是的,
没有使用过:是的,
老板:是的,
eqnull:true,
浏览器:是的,
全球:{
jQuery:true
}
},
Grunfile:{
src:'gruntfile.js'
},
lib_测试:{
src:['lib/***/.js','test/***/.js']
}
},
昆特:{
文件:['test/***/.html']
},
观察:{
Grunfile:{
文件:“”,
任务:['jshint:gruntfile']
},
lib_测试:{
文件:“”,
任务:['jshint:lib_test','qunit']
}
}
});
//这些插件提供了必要的任务
grunt.loadNpmTasks(“grunt-contrib-concat”);
grunt.loadNpmTasks(“grunt-contrib-uglify”);
grunt.loadNpmTasks(“grunt-contrib-qunit”);
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks(“grunt-contrib-watch”);
grunt.loadNpmTasks('grunt-bower-install');
//默认任务
registerTask('default',['jshint','qunit','concat','uglify']);
};
它告诉您项目目录中缺少一个package.json文件(“错误:无法读取”package.json“文件”)
正如您在这里看到的pkg:grunt.file.readJSON('package.json')
您的gruntfile尝试读取该文件
因此,创建package.json,然后重试grunt bower安装-这至少会让您开始
关于package.json文件的更多信息:您可以从项目的根目录运行grunt
命令。但是,从以下错误判断,我认为您运行了错误的grunt bower安装
子任务:
Running "bower-install:app" (bower-install) task
Verifying property bower-install.app.src exists in config...ERROR
>> Unable to process task.
Warning: Required config property "bower-install.app.src" missing.
如果您只需运行grunt bower安装
,它应该可以工作。要么那样,要么改名
'bower-install': {
target: { /* ... */ }
}
到