0
votes

I can't figure out my configuration problem. When I try to run 'grunt bowercopy', I get this error message:

Warning: Task "bowercopy" not found. Use --force to continue.

If I run 'grunt jshint', jshint works fine.

Here is my 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"
      }
    }

and here is my 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
Does your Gruntfile have grunt.loadNpmTasks('grunt-bowercopy'); in it somewhere? - max
Yes, it is at the bottom of the gruntfile, i guess the code is just a bit too long so you have to scroll inside the gruntfile to see it. - Ryan Quinn

3 Answers

4
votes

Run bower init to give yourself a bower.json file for the bowercopy task to read. Also if you already have installed everything via bower, set runBower to false in your options hash.

If you're ever having Grunt failures, it's worth running with the --v (verbose) flag to see exactly what it's failing on. Running this myself I saw it looking for a bower.json, and once I supplied one the task succeeded.

1
votes

You're missing task registration, You need to register a task that you want to explicity run in grunt, so you need this

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

Then you can run

grunt bowercopy
0
votes

Since I can't comment on @dcodesmith's answer due to points, I have to leave an answer. I ran into the problem in that actually adding grunt.registerTask('bowercopy', ['bowercopy']); called bowercopy's task, but it doesn't actually work. Removing it actually allowed bowercopy to copy files.