Skip to main content

Command Palette

Search for a command to run...

Node JS

Installation and Guide to Beginners

Published
2 min readView as Markdown
Node JS
V

M.Tech student at IIT Roorkee specializing in Advanced Instrumentation & Artificial Intelligence. I write about digital system design, FPGA-based hardware, signal processing, and the practical side of electronics—bridging fundamentals with real-world implementations.

This blog is about the Node.js platform, a popular choice for building scalable and reliable web applications. It covers a wide range of topics, including:

  • Getting started with Node.js

  • Building web applications with Node.js

  • Using Node.js for Microservices

  • Securing Node.js applications

  • Optimizing Node.js performance

  • Deploying Node.js applications

Installation

Now Check whether the node is installed in your computer or not by typing node--version on the hyper terminal.

Run a JS File by node

  • Open the VS Code terminal.

  • Type the node--version to get the node version and also check the installation of the node.

  • Go to the directory where the JS file is stored using cd "address of js file".

  • Now type node yourfilename.js (for eg: node index.js) and hit enter.

React Native Modules

const fs = require("fs")//file system

//For writing some text in a text file named message.txt using fs writefile module
fs.writeFile("message.txt","Hello, World!",(err)=>{
if (err) throw err;
console.log("The file has been saved");
});

//For reading some text from a text file named msg.txt using fs readfile module
fs.readFile("./msg.txt","utf8",(err,data)=>{
if (err) throw err;
console.log(data);
});

NPM Package Manager

Let we have to generate a random superhero name using the node then the following steps are involved for generating the superhero name

  • Open the VS Code terminal.

  • Initialise npm using npm init.

  • Install npm pacakges using npm i superheroes.

  • Open the package.json file and type in the file Type: "module".

  • Now open the js file and type the following code.

      import superheroes from "superheroes";
    
      const name = superheroes.random();
    
      console.log(name);