I think you need to remove the slashes from //require('load-grunt-tasks')(grunt) so it will load the dependencies in package.json
Question
I'm having problems creating a custom generator for Yeoman.
The structure of the folder and files generated is fine.
If I run the generator the there no errors and all the files are correct
The problem is creating the gruntfile.js.
If I run grunt serve I get the error - Warning: Task "express" not found. Use --force to continue.
The Gruntfile.js is a bit of a mash of bits I've found here and there so it could be anything.
Does anynone know of any tutorials explaining how to do this or can anyone see why this grunt file doesn't work.
// Gruntfile with the configuration of grunt-express and grunt-open. No livereload yet!
module.exports = function (grunt) {
'use strict';
// Load Grunt tasks declared in the package.json file
//require('load-grunt-tasks')(grunt);
// Configure Grunt
grunt.initConfig({
// grunt-express serves the files from the folders listed in `bases`
// on specified `port` and `hostname`
express: {
all: {
options: {
port: 9000,
hostname: '0.0.0.0',
bases: [__dirname],
livereload: true
}
}
},
// grunt-watch monitors the projects files
watch: {
all: {
files: ['index.html', 'css/**/*.css', 'js/**/*.js'],
options: {
livereload: true
}
}
},
// grunt-open will open your browser at the project's URL
open: {
all: {
// Gets the port from the connect configuration
path: 'http://localhost:<%= express.all.options.port%>'
}
}
});
// Creates the `server` task
grunt.registerTask('serve', [
'express',
'open',
'watch'
]);
};
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow