0

This seems pretty straightforward, but I can't seem to debug this error. I've added this code to my Sails API as /tasks/config/jshint.js

module.exports = function(grunt) {
  console.log(1);
  grunt.config.set('jshint', {
    files: {
      src: ['api/services/*.js', 'api/policies/*.js', 'api/controllers/*.js']
    }
  });
  console.log(2);
  grunt.loadNpmTask('grunt-contrib-jshint');
  console.log(3);
};

Now, when I execute any grunt task, I get an error message (but the older tasks still execute successfully).

C:\dev\fo-rest-api>grunt aglio
1
2
Loading "Gruntfile.js" tasks...ERROR
>> TypeError: undefined is not a function

Running "aglio:your_target" (aglio) task
...
Done, without errors.

When I run the jshint task, I get the same loading error and the task is aborted.

C:\dev\fo-rest-api>grunt jshint
1
2
Loading "Gruntfile.js" tasks...ERROR
>> TypeError: undefined is not a function
Warning: Task "jshint" not found. Use --force to continue.

Aborted due to warnings.

C:\dev\fo-rest-api>

A few other notes:

  1. Using --force only changes the wording of the error message.
  2. grunt-contrib-jshint seems to be successfully installed in /node_modules (I deleted everything and re-ran npm install to be sure.
  3. I'm running this on Windows, if that matters. I've tried opening the command line as both a normal user and as administrator.
  4. I tried commenting out the loadNpmTask line to see if sails would load it automatically, but still got Warning: Task "jshint" not found.

Thanks for any clues you might have.

carpiediem
  • 1,918
  • 22
  • 41

1 Answers1

0

The answer was pretty straightforward. I somehow deleted the s at the end of grunt.loadNpmTasks. When I added it back, everything worked well.

I wish there was some sort of syntax highlighting that for common packages like grunt that would identify this kind of typo...

carpiediem
  • 1,918
  • 22
  • 41