André Kirchner
André Kirchner

Reputation: 230

Grunt: Custom Task - No "taskname" targets found

I recently created a custom task, doing the following

  1. Created an empty folder "custom-tasks" in Document Root
  2. Created the task file itself: "mytask.js"
  3. Implemented the functionality
  4. Registered the task to the "Gruntfile.js"

Unfortunately Grunt is giving me the error - "No "mytask" targets found", whenever I call the task.

This is the part of my Gruntfile.js --> init section:

my-task: {
  all: {
    options: {
      input_folder: 'input',
      output_file: 'result/result.xml'
    }
  }
},

Below I load the tasks:

grunt.loadTasks('./custom-tasks')

Then I register my-task:

grunt.registerTask('test', ['my-task']);

Can someone please help me, I'm new to Grunt and would like to have my custom task working. But all I get is the No-target-error.

Thank you!!!

Upvotes: 0

Views: 420

Answers (2)

André Kirchner
André Kirchner

Reputation: 230

I solved the issue by rebuilding the script from scratch. Got a 'typo', so the task wasnÄt able to be executed. Unfortunately grunt told that there were issues with the targets, what wasn't exactly the case.

Thanks anyway!

Upvotes: 1

pedrommuller
pedrommuller

Reputation: 16066

try something like this:

'use strict';

module.exports = function(grunt) {
    // Project Configuration
    grunt.initConfig({
       pkg: grunt.file.readJSON('package.json'),
    },
    my-task: {
    all: {
      options: {
        input_folder: 'input',
        output_file: 'result/result.xml'
      }
    }
});

require('load-grunt-tasks')(grunt);
// Making grunt default to force in order not to break the project.
grunt.option('force', true);
grunt.registerTask('test', ['my-task']);

Upvotes: 0

Related Questions