Book Image

Learn Node.js by Building 6 Projects

By : Eduonix Learning Solutions
Book Image

Learn Node.js by Building 6 Projects

By: Eduonix Learning Solutions

Overview of this book

<p>With its event-driven architecture and efficient web services capabilities, more and more companies are building their entire infrastructure around Node.js. Node has become a de facto part of web development that any serious developer needs to master.</p> <p>This book includes six Node.js projects that gradually increase in complexity. You'll start by building a simple web server and create a basic website. You will then move to create the login system, blog system, chat system, and e-learning system.</p> <p>By creating and following the example projects in this book, you’ll improve your Node.js skills through practical working projects, and you'll learn how to use Node.js with many other useful technologies, such as ExpressJS, Kickstart, and Heroku.</p>
Table of Contents (12 chapters)

Sending chat messages


In the last section, we created our user interface in index.html; that's the only file we created. Now, we want to start to create our server, the Node.js server.

Creating the Node.js server

The first thing I will do is create a package.json file. We could manually create it, but I'll to open a command line into our projects folder and run npm init, and of course you have to have Node.js installed.

So, the name will be chatio, version will be 1.0.0, and description will be simple chat app. We'll change entry point to server.js. That's good and then put your own name so that should go ahead and create it:

I will add it to Sublime Text. Let's go to the C:\Projects\chatio. There's our package.json file. Now, we want to go in the code and add a couple dependencies. So, we'll say dependencies and add socket.io and express (latest versions) as shown in the following code snippet:

"dependencies": {
  "socket.io": "*",
  "express": "*"
}

Let's save that and we'll go back to our command...