Yeoman is a tool for scaffolding out a new web application, creating directories and files to get you started on your latest project. What makes yeoman different from similar tools however is that it champions a modern workflow through the use of Grunt for building and testing the application, and Bower for installing client-side dependencies.
Yeoman scaffolds applications by using generators. Generators are installed separately to to yeoman and are usually geared towards a certain type of project e.g. generator-angular for angularjs projects or generator-chrome-extension for creating chrome extensions. A full list of generators is available here.
At the moment most of the yeoman generators are geared towards front-end development, I found it great to use to quickly get started with a new project and saw no reason why I couldn't use it to generate the starting point for a server-side application.
The Generator
I've created a generator that scaffolds an expressjs application. This contains 2 generators:
- The basic generator which is based on the
express
command line utility with added grunt tasks and bower setup. - An MVC style generator which is based around node-express-mongoose-demo
Getting Started
- Make sure you have yo installed
npm install -g yo
- Install the generator locally:
npm install generator-express
- Run:
yo express
for the basic generator ORyo express:mvc
for the MVC generator - Run:
grunt
this will run a local server atlocalhost:3000
Once the server is running you can edit client-side or server-side files and once saved the browser will automatically refresh and show your changes. This is done through the grunt-contrib-watch
task, which can be viewed and edited in the Gruntfile.js
.
You can use bower
to install client-side packages which will be placed into the public/components
directory. For example using bower install jquery
will download and install jquery to public/components/jquery
.