The best way to learn any new technology is to try it out using some practical examples. So, let's go ahead and build an Express app and find out how it works.
To ensure our experiments do not mess up our filesystem, let's create a directory named express-app
in your home directory and build our app there:
$ cd ~ $ mkdir express-app $ cd express-app
The app directory is ready and we can start building our first Express app.
In Chapter 1, What is Express?, we learned that Express apps are actually Node modules, which means our app also would need a manifest file. So, create a file named package.json
in the app directory.
The package.json
file can have more than a dozen fields, but for the sake for brevity, let's keep it minimal. Here is what it should look like:
{ "name": "test-app", "version": "0.0.1", "private": true, "scripts": { "start": "node app" }, "dependencies": { "express": "3.2.6", "jade": "*" } }
The fields used...