Then we can initiate our project by the following command: npm init We can start by creating a new project directory and moving into it. For simplicity we will be avoiding the authentication part. The messages must be updated without refreshing the page. The app must allow multiple users to chat together. These will be explained further on as needed. There are many frameworks that can be added as modules to our Node application. This file can be created by this command: npm initĪnd the packages must be installed as follows: npm install -s module_name In Node apps we will be using a package.json file to maintain the module versions. The third party modules can be installed using the following command: npm install module_nameĪnd the installed modules can be used using the require() function: var module = require(‘module_name’) These modules can be user-defined or third party modules. Nodejs allows the modules of libraries to be included in the application. Also the JavaScript works well with JSON and No-SQL databases. The asynchronous behaviour can be implemented using callbacks. For example, Node can process other things while a file is being read off disk, or while waiting for an HTTP request to complete. Node.js lets developers use JavaScript to write Command Line tools and for server-side scripting - running scripts server-side to produce dynamic web page content before the page is sent to the user’s web browser.Įven though the node is single threaded it’s still faster to use asynchronous functions. The most important advantage of using Node is that we can use JavaScript as both a front-end and back-end language.Īs we know, JavaScript was used primarily for client-side scripting, in which scripts were embedded in a webpage’s HTML and run client-side by a JavaScript engine in the user’s web browser. Node.js is an open-source, cross-platform JavaScript run-time environment that executes JavaScript code outside the browser. We will use the JavaScript framework Express.js and the libraries Mongoose and Socket.io to achieve this.īefore we start, lets have a quick look at the basics of Node.js Node.js In this tutorial, we will use the Node.js platform to build a real time chat application that sends and shows messages to a recipient instantly without any page refresh. By Arun Mathew Kurian How to build a real time chat application in Node.js using Express, Mongoose and Socket.io
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |