Training Guide: Programming in HTML5 with JavaScript and CSS3 Ebook

(Nora) #1

Practice exercises CHAPTER 8 383


project. From the Node.js perspective, all the files are in its website, but you can still open the
WebCalculator solution in Visual Studio as needed.


  1. If you haven’t done so yet, install Node.js from http://nodejs.org/.

  2. Open the command prompt window.

  3. Create a folder for the new website.
    This requires you to navigate to the location and then create the folder. For example,
    the following commands navigate to the Practice Exercises folder on the root of the
    C drive, create a new ContosoWeb folder, and then navigate to the new folder.
    C:
    cd \Practice Exercises
    md ContosoWeb
    cd ContosoWeb

  4. In the Resources folder, find the WebCalculator solution. Copy the solution and paste it
    into the ContosoWeb folder.

  5. In the ContosoWeb folder, create a package.json file by typing the following command.
    npm init


This command starts the wizard. Enter the following.
■■name: ContosoWeb
■■version: 0.0.0
■■description: Contoso Web Site
■■main: index.js
■■keywords: Contoso, WebCalculator
■■author: your name
■■license: BSD


  1. Open the package.json file and add a dependency on the express and formidable
    packages, as shown in the following modified package.json file.
    {
    "name": "ContosoWeb",
    "version": "0.0.0",
    "description": "Contoso Web Site",
    "main": "index.js",
    "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
    },
    "repository": "",
    "keywords": [
    "Contoso",
    "WebCalculator"
    ],
    "author": "Glenn Johnson",
    "license": "BSD",
    “dependencies”: {

Free download pdf