Reputation: 8240
I got node.js installed on Windows with npm package.
I have a project in D drive as D:>projectD
I am trying to run jshint along with SASS,concat,etc. All are working fine, but getting error on jshint as:
Local npm module "jshint" not found.Is it installed?
Warning: Task 'jshint' not found. Use --force to continue.
For installation of jshint used the following commands:
npm install -g jshint
D:>projectD>npm install --save-dev jshint
Gruntfile.js
jshint:{
all: ['<%= meta.srcPath %>engine/js/myjs1.js']
},
//plugin declaration
grunt.loadNpmTasks('jshint');
// Default task
grunt.registerTask('default', ['concat','sass','jshint']);
Package.json
{
"name": "Test-Project",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-concat": "~0.1.3",
"grunt-sass": "^1.0.0",
"jshint": "^2.8.0"
}
}
Can someone help me out why I am not able to work with jshint along with other tasks in grunt?
Upvotes: 0
Views: 252
Reputation: 1428
Actually your Gruntfile is wrong.
You want to configurate Grunt. Therefore you need to init the configuration by using grunt.initConfig
So in your case
grunt.initConfig({
jshint: {
all: ['<%= meta.srcPath %>engine/js/myjs1.js']
}
});
And I believe that the module is the grunt-contrib-jshint
module which you need.
So your loadNpmTask would be grunt.loadNpmTasks('grunt-contrib-jshint');
And your registerTask
only needs to contain jshint
since you do only load and configurate jshint
.
You are missing the module.exports = function(grunt) { }
. You need to export your configuration as a function.
All in all your configuration should look like the following
module.exports = function(grunt) {
grunt.initConfig({
jshint: {
all: ['<%= meta.srcPath %>engine/js/myjs1.js']
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('default', ['jshint']);
};
Upvotes: 1