WEB Advent 2012 / Node.js with Express.js in Business

The fundamental processes behind business and software development are very different, and it’s often the reason why getting the two working together can be challenging.

In business, you’re often able to test ideas quickly and without major costs, which means that an experimental approach to development is common. In software development, you aren’t able to test your ideas as quickly, because you need things to be stable and that costs time and money. This means that software development depends on well-specified needs that business people have a hard time articulating, because they are not used to doing that.

There are many ways to go about improving this. One option is prototyping, and another option is for the business people to acquire a better understanding of how software development works, thereby improving the foundation for good communication.

I think learning Node.js with Express.js can be a great way for business people to gain an understanding of how software development works that lets them improve the relationship in two different ways: by building prototypes that can help them explain what they want, and by being better at speaking the language of developers.


Node.js is JavaScript, and the very expressive nature of the language makes the code relatively easy to understand. This lets you learn as you go with a very limited understanding of the language. That might not be the optimal way to go about it, but it builds motivation that keeps you going.

It has a big and active community that builds awesome frameworks and modules, so when obstacles arise, chances are good that you can find a module or a fellow developer that can help you out. This keeps you moving forward.

Node can be used to a lot of other things too, like building a web or chat server, and that encourages you to try and understand how it all works together, and it makes you feel very empowered by just learning one language.


Building web apps with Node lets you iterate and change the structure of your app very easily, because it is JavaScript on both the server side and the client side. Express.js is one of the most popular web app frameworks for Node, and it takes care of a lot of things while remaining light and flexible. This fits an experimental and iterative approach very well.

It’s super easy to install, and it’s amazing how quickly you can get an app running. The only steps you need to go through are1:

  • Install Express.js: npm install express
  • Generate the app: express myapp
  • Install dependencies: cd myapp && npm install
  • Run the app: node app
  • Access the app at: localhost:3000

Express defaults to using Jade, which is a template engine (in other words, a different way to write HTML and insert data into it) for Node. But, if you prefer using HTML and Handlebars.js, you can do that. First, install a few packages:

npm install html
npm install hbs

Next, change some settings. In the app.js file, change app.set('view engine', 'jade') to app.set('view engine', 'html').

Then, configure the app to use hbs by adding this line:

app.engine('html', require('hbs').__express);

Now, rename index.jade to index.html and have it print the title with HTML and Handlebars.js:


Relaunch2 the app, go to localhost:3000, and it should display the title that is set in the route.


The framework doesn’t make any assumptions in terms of how you want to structure your code, so you’re free to do what makes sense to you for the current project. That can be a bit confusing at first, so let’s look at an example of how you’d begin the development of an app.

Let’s say that you want to have a page that shows some numbers about your business. To handle that, you’ll need a new route and a view, and you’ll have to tell the app where you want the page to be.

  1. Add a numbers.js file to the routes directory, and paste in the code from the index route. Configure it to render the numbers view instead of the index view.
  2. Add a numbers.html file to the views directory.
  3. Add this line to your app.js file: app.get('/numbers', routes.numbers);

By adding this line of code, the numbers route will be called when /numbers is requested, and the route will then grab the data and render the view.

You can now start adding logic to the route that gets the data you need, but you’ll soon need a model that can take care of pulling in data from other services such as a database. Express doesn’t suggest a place to keep the models, but as long as you only have a few, just put them in the root directory. As you app grows, and you get more routes, views, and models, you can adjust the structure to your liking, and by that time, you’ll know exactly what that is.


In summary, Node.js with Express.js is great for business people, because it’s easy to learn, it can be used to do a lot of different things, and it encourages you to understand how the Web works. It empowers you to build things quickly and iterate until you’re happy, which is a great way to prototype and demonstrate your ideas.

So, if you’re a business person (we all are), and you have ideas that you’d love to see brought to life (we all do), consider Node.js with Express.js. It’s awesome.


  1. Assuming that you’re on a Mac and have Node.js and NPM installed. If you don’t already have Node.js installed, head over to nodejs.org. Return to footnote 1 source.

  2. Nodemon is a great tool that automatically relaunches the app when you save. So, if you don’t like to constantly relaunch it, this will be your friend. Return to footnote 2 source.

Other posts