What Is Node and When Should I Use It?
Node.js is an open source server environment,is free, runs on various platforms and uses JavaScript on the server.
Why Node.js?
A common task for a web server can be to open a file on the server and return the content to the client.
What Can Node.js Do?
-
Node.js can generate dynamic page content.
-
Node.js can create, open, read, write, delete, and close files on the server.
-
Node.js can collect form data.
-
Node.js can add, delete, modify data in your database.
What is a Node.js File?
- Node.js files contain tasks that will be executed on certain events.
-
A typical event is someone trying to access a port on the server.
-
Node.js files must be initiated on the server before having any effect.
- Node.js files have extension “.js”.
Initiate the Node.js File
Start your command line interface, write node myfirst.js.
The Built-in HTTP Module
use the require() method.
Node.js as a Web Server
Use the createServer() method to create an HTTP server.