Yeoman generator for MEAN stack projects
To use the generator, you need some prerequisites :
- Node.js with NPM
- MongoDB (only needed if you want to use a local database, you could use a MongoDB web service like Mongolab too, but for development purpose it could be useful to have a local database)
- Yo - This package manage all Yeoman's generators
$ npm install -g yo
- Bower - Bower will manage your frontend dependencies
$ npm install -g bower
- Grunt - Grunt will automate some tasks to build your app or check if there's no error in your code.
$ npm install -g grunt-cli
Install the generator
$ npm install -g generator-mean-stack
Make a new directory and cd into it
$ mkdir -p mean-project && cd $_
Scaffold a new MEAN stack project
Note: If you want to test user authentication in the new generated project, you need to leave ngRoute, ngCookies and nodemailer
You also need Bootstrap and Font Awesome to get the good demo project style
- mean-stack (or mean-stack:app)
- mean-stack:bModel (coming soon)
- mean-stack:fRoute (coming soon)
Note: Generators are to be run from the app root directory
Sets up a new MEAN stack app, generating all the boilerplate you need to get started.
$ yo mean-stack
Sets up a new route in Express router (located in
You can choose if the route has a restricted access (only for users) and if you want a ready CRUD template.
$ yo mean-stack:bRoute
Note: CRUD will create a route AND start the bModel sub-generator to set up a new Mongoose model
If you want to skip bModel generator, use the
$ yo mean-stack:bRoute --skip-model
Create a new Mongoose model (located in
Suggestion: If you have to make a new route too, use
yo mean-stack:bRoute instead
$ yo mean-stack:bModel
Serve and build
The generator makes a gruntfile configuration, so building your app becomes easy.
Build a fresh new distribution :
Run the app server in development mode :
$ grunt serve
You can define a
production target to serve in production mode :
Note: this last command builds automatically a new distribution before serving.
Make sure to test your final distribution with Grunt :
$ grunt serve:production
The final distribution is located in
$ cd build
Everything you need is here, you can init a git repo here and push your build :
git init && git remote add origin pathToYourProductionServer && git commit -am "Build 1.0.0" && git push origin master
Note: Make sure to configure your .gitignore file inside /build directory to match with your production server specifications.
Note2: .git folder and .gitignore file won't be overwritten during new build, but you can add other files too in Gruntfile.js configuration.