• Home
  • What is ?
  • DSA
  • MAD
  • Concept
  • Practice
  • Misc
  • Quiz
  • YT
  • Home
  • What is ?
  • DSA
  • MAD
  • Concept
  • Practice
  • Misc
  • Quiz
  • YT
  • #News
  • #APPS
  • #Events
    • #WWDC
    • #I/O
    • #Ignite
  • #Let’s Talk
  • #Interview
  • #Tips

MyCodeTips mycodetips-newlogocopy1

  • Home
  • What is ?
  • DSA
  • MAD
  • Concept
  • Practice
  • Misc
  • Quiz
  • YT
Javascript, Programming

How to Install NODE-JS ?

How to Install NODE-JS ?

NODE-JS

Using Website:
You can visit on the link Download Node and download LTS version.
After installing node you can check your node version in command prompt using command..

~ $node --version

After that, you can just create a folder and add a file here for example app.js. To run this file you need to execute command…

first app $node app.js

Node Modules: There are some built-in modules which you can use to create your applications. Some of the popular modules are- OS, fs, events, HTTP, URL and then you can include these modules in your file using these lines.

var fs = require('fs');

Here is an example of how to include HTTP module to build the server…
filter_none
brightness_4

var http = require('http'); 

// Create a server object: 
http.createServer(function (req, res) { 

// Write a response to the client 
res.write('mycodetips'); 

// End the response 
res.end(); 

// The server object listens on port 8080 
}).listen(8080);

This will listen to server on port 8080. Once you will run your file in command prompt it will execute your file and listen to the server on this port. You can also create your own module and include in your file.

Using NPM: NPM is a Node Package Manager provides packages to download and use. It contains all the files and modules that you require in your application. To install any package you need to execute command…

npm install

I am going to show an example of using Events module.

filter_none
brightness_4

var events = require('events'); 
var eventEmitter = new events.EventEmitter(); 

// Create an event handler: 
var myEventHandler = function () { 

console.log('Welcome tomycodetips'); 
} 

// Assign the event handler to an event: 
eventEmitter.on('mycodetips', myEventHandler); 

// Fire the 'mycodetips' event: 
eventEmitter.emit('mycodetips');

So this is how you can start with node and build your own applications. There are some frameworks of the node which you can use to build your applications. Some popular frameworks of node are…Express.js, Socket.io, Koa.js, Meteor.js, Sail.js.

Liked it? Take a second to support Ranjan on Patreon!
Become a patron at Patreon!
  • Click to share on Reddit (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • More
  • Click to share on Pocket (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
Written by Ranjan - 1154 Views
AUTHOR
Ranjan

Namaste, My name is Ranjan, I am a graduate from NIT Rourkela. This website is basically about of what i learnt from my years of experience as a software engineer on software development specifically on mobile application development, design patterns/architectures, its changing scenarios, security, troubleshooting, tools, tips&tricks and many more.

Next Post
Previous Post

Support us

mycodetips
mycodetips

Follow us @ LinkedIn 2850+

Subscribe for updates

Join 8,213 other subscribers

Latest Posts

  • YT-Featured-solidprinciples
    SOLID Principles of Software Design
  • IOS 16 Features
    Latest features in IOS 16
  • r-language
    How can R language be used for data analysis?
  • wordpress-coding-blog
    Guide To WordPress Coding Standards
  • YT-Featured-Algorithm
    What is Algorithm?
whiteboard

Whiteboard(PRO)

whiteboard

Whiteboard(lite)

alphabets

Kids Alphabet

techlynk

Techlynk

techbyte

Do2Day

techbyte

Techbyte

  • #about
  • #myapps
  • #contact
  • #privacy
  • #Advertise
  • #myQuestions

Android Android Studio API APP Programming Apps blogging CSS DATABASE dsa Features HTML HTML5 installation Interview Questions IOS iPhone javascript Mac objective-c OS Programming quicktips SDK SEO SQL swift Tips & Tricks Tools UI Web Wordpress Xcode

  • SOLID Principles of Software Design
  • Latest features in IOS 16
  • How can R language be used for data analysis?
  • Guide To WordPress Coding Standards
  • What is Algorithm?

©mycodetips.com