Today is the day I embark on my journey with Grunt for testing my JavaScript code. All the necessary grunt modules have been successfully installed and are documented in a json file called package.json.
{
"name": "LarissaCity",
"private": true,
"devDependencies": {
"grunt": "^1.0.1",
"grunt-contrib-jshint": "^1.1.0",
"jit-grunt": "^0.10.0",
"jshint-stylish": "^2.2.1",
"time-grunt": "^1.4.0"
},
"engines": {
"node": ">=0.10.0"
}
}
Furthermore, I have prepared a Gruntfile.js file where I will utilize these installed modules to put my JavaScript code to the test.
'use strict';
// Keep track of how long tasks take to optimize build times
require('time-grunt')(grunt);
// Load required Grunt tasks automatically
require('jit-grunt')(grunt);
// Configuration for all tasks
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: {
src: [
'Gruntfile.js',
'app/scripts/{,*/}*.js'
]
}
}
});
grunt.registerTask('build', [
'jshint'
]);
grunt.registerTask('default',['build']);
Upon running the command grunt, an error message pops up stating:
Loading "Gruntfile.js" tasks...ERROR
ReferenceError: grunt is not defined
This indicates that there might be an issue in the Gruntfile.js. Any suggestions or insights would be greatly appreciated.
Thank you,
Theo.