The Node Beginner Book » A comprehensive Node.js tutorial How To Node - NodeJS Express - guide Getting started With node installed (download), get your first application started by creating a directory somewhere on your machine: $ mkdir hello-world In this same directory you'll be defining the application "package", which are no different than any other node package. Now that you have a package.json file in this directory you can use npm(1) to install the dependencies, in this case just Express: $ npm install Once npm finishes you'll have a localized Express 3.x dependency in the . $ npm ls email@example.com /private/tmp └─┬ firstname.lastname@example.org ├── email@example.com ├─┬ firstname.lastname@example.org │ ├── email@example.com │ ├── firstname.lastname@example.org │ ├── email@example.com │ ├── firstname.lastname@example.org │ └── email@example.com ├── firstname.lastname@example.org ├── email@example.com ├── firstname.lastname@example.org ├── email@example.com ├── firstname.lastname@example.org ├── email@example.com ├─┬ firstname.lastname@example.org │ └── email@example.com └─┬ firstname.lastname@example.org └── email@example.com Now to create the application itself! var express = require('express'); var app = express(); Using express(1) to generate an app Then fire it up!
blog.gvm-it.eu, Callback conventions in node.js, how and why Callback conventions in node.js, how and why When first confronted with node.js, you are not only presented with a completely new programming environment. You also encounter what is often referred to as callback hell accompanied by weird unfamiliar programming patterns. One of these is the way node treats callback functions. The following post explains the conventions that node.js uses for its callback patterns (referred to as Continuation-passing style) and how you should implement them in order to comply. The first argument is an error object Node expects - almost - all callback functions to accept an Error object as the first argument. There is a reason why this is a usefull pattern: Imagine, you have a chain of asynchroneous functions that were to execute one after the other. Now think something went wrong in the first function, i.e. the file cannot be read. This pattern lets you waterfall through function chains and leaves handling the error it up to the original invoking function.