Training Guide: Programming in HTML5 with JavaScript and CSS3 Ebook

(Nora) #1

Lesson 1: Getting started with Node.js CHAPTER 8 355


"version": "0.0.0",
"description": "A simple Web site",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": "",
"author": "Glenn Johnson",
"license": "BSD"
}
Open the file with a text editor and add the dependency to express as follows.
{
"name": "HelloExpress",
"version": "0.0.0",
"description": "A simple Web site",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": "",
"author": "Glenn Johnson",
"license": "BSD”,
“private”: true,
“dependencies”: {
“express”: “3.0.0”
}
}
The version number could have been set to “3.x” to retrieve the latest of version 3, and
private is set to true, which indicates that this application will be used only locally. If you don’t
supply the private indicator, you might get a message from your firewall provider stating that
the website is running with limited functionality.
Now that you have the dependency to express configured, you can use npm to install all
dependencies by executing the following command.
npm install

This installs express and all its dependencies into the node_modules folder. You can verify
that express is installed by executing the following command.
npm ls

This command provides a list of packages installed for this application. You see that
express is installed, but many other packages are also installed, as shown in Figure 8-7.
Free download pdf