Setting Up Your Project

In this unit, you install and run the ECMAScript 5 version of the Employee Directory application that we use as a starting point for this tutorial:

Steps

Follow the instructions below to install the ECMAScript 5 version of the application:

  1. Clone the es6-tutorial-data repository:

    git clone https://github.com/ccoenraets/es6-tutorial-data
    
  2. Navigate (cd) to the es6-tutorial-data directory.

  3. Type the following command to create a package.json file:

    npm init
    

    Press the Return key in response to all the questions to accept the default values.

  4. Install http-server in your project. http-server is a lightweight web server we use to run the application locally during development and avoid cross domain policy issues when loading data using XMLHttpRequest.

    npm install http-server --save-dev
    
  5. Open package.json in your favorite code editor. In the scripts section, remove the test script, and add a script named start that starts the local web server. The scripts section should now look like this:

    "scripts": {
        "start": "http-server"
    },
    
  6. On the command line, type the following command to start the HTTP server:

    npm start
    

    If port 8080 is already in use on your computer, modify the start script in package.json and specify a port that is available on your computer. For example:

    "scripts": {
        "start": "http-server -p 9000"
    },
    
  7. Open a browser and access http://localhost:8080 to run the application.

comments powered by Disqus