generator-node-express

0.0.3 • Public • Published

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:

  • Express.js
  • Express3-Handlebars for templating
  • Sass for styling
  • Javascript linting
  • It will open your project in your editor of choice
  • It will open your project in a browser of your choice
  • It will watch for changes to your files and recompile or restart the server if needed.
  • Uses LiveReload to refresh the browser when saving
  • It will build a production version of your app when you are ready to deploy
  • It comes ready to deploy to Heroku

Optional tools

Installing this generator

With Node and npm installed run this to install.

$ npm install -g generator-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.

LiveReload

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.

Restarting the server

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

Generate a production version of your app

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

Things to do

  • Add test driven development.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.3
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.3
    1
  • 0.0.2
    0
  • 0.0.1
    0

Package Sidebar

Install

npm i generator-node-express

Weekly Downloads

1

Version

0.0.3

License

none

Last publish

Collaborators

  • lukelarsen