Question

I am using:

grunt-cli v0.1.11
grunt v0.4.1

Here is my package.json

{
  "name": "Example",
  "version": "0.0.1",
  "private": true,
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-cli": "~0.1.11",
    "grunt-contrib-jshint": "~0.7.1"
  }
}

Here is my gruntfile.js

module.exports = function(grunt) {

  grunt.initConfig({
    jshint: {
      src: ['Gruntfile.js', 'src/app/**/*.js', 'src/config.js', 'tests/app/**/*.js'],
      options: {
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: true,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        boss: true,
        eqnull: true,
        browser: true,
        globals: {
          require: true,
          define: true,
          requirejs: true,
          describe: true,
          expect: true,
          it: true
        }
      }
    }
  });

  // Load JSHint task
  grunt.loadNpmTasks('grunt-contrib-jshint');

  // Default task.
  grunt.registerTask('default', 'lint');

};

I have installed: grunt-contrib-jshint package and I can see it in the node_modules directory.

When I do:

> grunt

I expect the default lint task to execute but instead I get:

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

Any ideas?

Was it helpful?

Solution

You need to rename lint to jshint.

Alternatively, add a task alias

grunt.registerTask('lint', ['jshint']);

I've noticed you have grunt-cli as a devDependency, but you should install it globally instead of listing it in your package.json

npm i -g grunt-cli
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top