generator-node-express
v0.0.3
Published
A generator for Yeoman that will kick start a Node Application using Express.
Downloads
5
Readme
generator-node-express
A generator for Yeoman.
Getting Started
What is Yeoman?
From the default Yeoman Generator:
Basically, he wears a top hat, lives in your computer, and waits for you to tell him what kind of application you wish to create.
Not every new computer comes with a Yeoman pre-installed. He lives in the npm package repository. You only have to ask for him once, then he packs up and moves into your hard drive. Make sure you clean up, he likes new and shiny things.
To install Yeoman you will need to have npm (node packaged modules) installed. It comes with Node. You can install Node by using the downloader or through Brew. I like Brew. If you use Brew you'll need to add this to your .bash_profile.
homebrew=/usr/local/share/npm/bin
Here is a post on installing Node if you need it.
Once Node is installed you'll have access to npm so you can use this to install Yeoman.
$ npm install -g yo
The -g means that you are installing Yeoman globally. If you wish to uninstall Yeoman you can do so with this command.
$ npm uninstall -g yo
What's included in this generator
This generator uses some tools I find useful. Those include:
Optional tools
Installing this generator
Most generators can be installed the same way you installed Yeoman. This generator hasn't made it into the Yeoman registry yet. In order to use it you will need to download it to a directory of your choice, then cd to that directory and run this command:
$ npm link
This enables you to access the generator globally to run it. You won't need to do that once this generator makes it into the registry. If you'd like to remove this link in the future you can use this command:
$npm unlink node-express
Using this generator
With the generator installed it is time to run it. Create a directory on your computer somewhere and cd into it via the terminal. Then run:
$ yo node-express
Yeoman will ask you some questions. Answer them and it will install stuff based on your answers.
Once Yeoman is done setting up your project run this command to start working on it.
$ grunt workon
This starts the server, launches the project in your editor, opens the project in a browser, and starts watching the project for changes.
To enable LiveRelaod you'll need to install the Chrome extension.
Live Reload Chrome extension
Once installed and the project is running just turn on the Chrome Extension.
When you edit files that need the server to restart for you to see the changes, most of the time Grunt will just restart it for you. There are times when it gets stuck though. If this happens you can run this command to start it back up without reopening the project in your editor and browser.
$ grunt restart
Once your app is ready for production run this to generate a production build of your project.
$ grunt build
To test to see if the app is using the production version of the app you can shut down the server and start it again in production mode.
$ NODE_ENV=production node app.js
If it all works you are ready to deploy to Heroku. The Procfile at the root directory is for Heroku. Without it Heroku will choke. To deploy to Heroku you will need a Heorku account and the Heroku Toolbelt installed.
Once that is setup use Git to commit and then Heroku to create and deploy.
$ git init
$ git add .
$ git commit -m 'init'
Create the app
heroku create
Deploy your code
git push heroku master
To ensure that Heroku is setup to use your production settings you'll need to run this:
$ heroku config:set NODE_ENV=production
Open the project
heroku open