Yeoman custom generator - Grunt error
Hi all
I’ve started using Yeoman to start projects - http://yeoman.io
The generators avaiable are great but I wnated create my own to fit exactly what I need.
The actual structure is fine I can run my generator and the structure I want is created.
My pronblem is with Grunt.
I just want it to watch for any changes at the moment, do a simple html validate, and open the page in the server.
This is the package.json
{
"name" : "appname",
"version" : "0.1.0",
"private" : true,
"devDependencies" : {
"grunt" : "~0.4.0",
"grunt-contrib-watch": "*",
"grunt-htmlhint": "*"
}
}
and this is the gruntfile.js
module.exports = function(grunt){
"use strict";
grunt.loadNpmTasks('grunt');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-htmlhint');
grunt.initConfig({
watch: {
html: {
files: ['index.html'],
tasks: ['htmlhint']
}
},
htmlhint: {
build: {
options: {
'tag-pair': true,
'tagname-lowercase': true,
'attr-lowercase': true,
'attr-value-double-quotes': true,
'doctype-first': true,
'spec-char-escape': true,
'id-unique': true,
'head-script-disabled': true,
'style-disabled': true
},
src: ['index.html']
}
},
express: {
all: {
options: {
port: 9000,
hostname: '0.0.0.0',
bases: [__dirname],
livereload: true
}
}
},
open: {
all: {
// Gets the port from the connect configuration
path: 'http://localhost:<%= express.all.options.port%>'
}
}
});
grunt.registerTask('server', [
'express',
'open'
]);
};
If I run Yeoman with ‘yo basic’ (the name of the generator) the all the files and folders are created.
I then run ‘npm install’ to download the dependencies, which works and all the dependencies are added
If I then run ‘grunt server’ I get the error
>> Local Npm module "grunt" not found. Is it installed?
Warning: Task "express" not found. Use --force to continue.
Does anyone have any experience creating generators for Yeoman?
The documentaion for it isn’t good at all.