找不到grunt bowercopy任务

时间:2014-01-25 04:15:39

标签: node.js gruntjs bower

我无法弄清楚我的配置问题。当我尝试运行'grunt bowercopy'时,我收到此错误消息:

警告:未找到任务“bowercopy”。使用--force继续。

如果我运行'grunt jshint',jshint工作正常。

这是我的package.json:

{
     "name": "treblebull",
      "version": "0.0.1",
      "private": true,
      "dependencies": {
        "express": "~3.2.6",
        "jade": "~0.31.2",
        "underscore": "~1.5.2",
        "pg": "~2.11.1"
      },  
      "devDependencies": {
        "grunt": "~0.4.2",
        "grunt-bowercopy": "~0.7.1",
        "grunt-contrib-jshint": "~0.8.0",
        "load-grunt-tasks": "~0.2.1"
      }
    }

这是我的gruntfile:

    'use strict';

    module.exports = function(grunt) {

      grunt.initConfig({
        jshint: {
          options: {
            jshintrc: '.jshintrc'
          },  
          gruntfile: {
            src: 'Gruntfile.js'
          },  
          lib: {
            src: ['lib/**/*.js']
          },  
          test: {
            src: ['test/**/*.js']
          }   
        },  
        bowercopy: {
          options: {
            clean: true
            //srcPrefix: 'bower_components'
          },  
          libs: {
            options: {
             // destPrefix: 'public/js/lib'
            },  
            files: {
              'angular.js': 'angular/angular.js'
              //'underscore.js': 'underscore/underscore.js',
              //'underscore.string.js': 'underscore.string/underscore.string.js'
            }   
          }   
        }   
      }); 

      grunt.loadNpmTasks('grunt-bowercopy');
      grunt.loadNpmTasks('grunt-contrib-jshint');

    };

3 个答案:

答案 0 :(得分:4)

运行bower init为自己提供一个bower.json文件,供bowercopy任务阅读。此外,如果您已经通过凉亭安装了所有内容,请在runBower哈希中将false设置为options

如果您曾经遇到Grunt失败,那么值得使用--v(详细)标志运行,以确切了解其失败的原因。自己运行这个我看到它寻找bower.json,一旦我提供了一个任务成功。

答案 1 :(得分:1)

您缺少任务注册,您需要注册一个您想要在grunt中明确运行的任务,因此您需要这个

grunt.registerTask('bowercopy', ['bowercopy']);

然后你可以运行

grunt bowercopy

答案 2 :(得分:0)

由于点数不能评论@ dcodesmith的回答,我不得不给出答案。我遇到了问题,实际上是在添加grunt.registerTask('bowercopy', ['bowercopy']); 称为bowercopy的任务,但它实际上并不起作用。删除它实际上允许bowercopy复制文件。

相关问题