Setup

Creating an express app

  1. Install express

     npm install express -g
    
  2. Initiate a new app

     express --sessions storeski
    

    This will create the foundation for your application. For complete list of express option type express --help in the terminal

  3. Use node-supervisor to start the server.

    node-supervisor is a little supervisor script for nodejs. It runs your program, and watches for code changes, so you can have hot-code reloading-ish behavior, without worrying about memory leaks and making sure you clean up all the inter-module references, and without a whole new require system.

    package.json file add:

     "supervisor": "0.4.x"
    

    Also modifying "scripts" "start" command to use supervisor

     "scripts": {
       "start": "node_modules/.bin/supervisor app"
     },
    

    We are doing a couple things here:

    1. We are using npm scripts: This allows us to start the server using the command npm start
    2. We are using the local supervisor script that will be present in the node_modules/.bin directory after we run npm install
  4. Update modules

     npm install
    
  5. Start the server

     npm start
    

    For more information npm scripts please read npm scripts

  6. View your creation

    http://localhost:3000

Resources

Comments