Introduction
In this article, I am going to introduce NodeJS with Node Package Module (NPM), step-by-step basic implementation and explanation.
This article covers the following areas of NodeJS.
- Introduction of NodeJS
- Installation of NodeJS and NPM
- Node Package Module (NPM)
- Package.json
- Basic Example
NodeJS
NodeJS is an open-source, cross-platform runtime environment for developing server-side web applications. NodeJS also has an event-driven architecture capable of asynchronous I/O.
NodeJS uses an event-driven, non-blocking I/O model that makes it lightweight and efficient.
Installation of NodeJS and NPM
Installation of NodeJS and NPM is straightforward using the installer package available at NodeJS official web site.
- Download the installer from NodeJS WebSite.
- Run the installer.
- Follow the installer steps, agree the license agreement and click the next button.
- Restart your system/machine.
Now, test NodeJS by printing its version using the following command in Command Prompt:
1> node -v
and test npm by printing its version using command
1> npm -v
Simple way to test nodeJS work in your system is to create a javascript file which print a message.
Lets create test.js file
1/*test.js file*/
2console.log("Node is working");
Run the test.js file using Node command > node test.js
in command prompt.
You are done with installation.
Node Package Module
NPM is the package module which helps javascript developers load dependencies effectively. To load dependencies we just have to run a command in command prompt:
1> npm install
This command is finding a json file named as package.json
in root directory to install all dependencies defined in the file.
Comments
Post a Comment