Loading

Node.js

How to work with Node.js and JSON file ?. The Complete Node.js Developer Course 2023 [Videos].

Node.js is a platform built on Chromes JavaScript runtime for easily building fast and scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices

console.log("Hello Node.js!");

Running a Script: We can run a Node.js script using the node app.js command. Open a terminal window and navigate to the directory where the script exists. 
 

Output:  

Hello Node.js

Importing Node.js Core Modules: Node.js contains some built-in modules. These modules are comes with Node, so no installation is required for them. One of the most used module is file system or fs module. The fs module provides an API for interacting with the file system or basically it provides functions that we can use to manipulate the file system. For importing any module, we make use of the require() function. The script uses writeFileSync to write a message to demo.txt. After running the script, we will find the demo.txt file with the data written the same as the given parameter in writeFileSync function. If the ‘demo.txt’ file doesn’t exist in the directory a new file with the same name is created. 
 const fs = require("fs")

 
//  Writing to a file
fs.writeFileSync("demo.txt", "geeks")

See All

Comments (129 Comments)

Submit Your Comment

See All Posts

Related Posts

Node.js / Youtube

How to Create Node.js Web Server?

Node.js is a platform built on Chromes JavaScript runtime for easily building fast and scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices
27-jan-2021 /3 /129

Node.js / Youtube

What is Node.js?

Node.js is a platform built on Chromes JavaScript runtime for easily building fast and scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices
27-dec-2020 /3 /129

Node.js / Youtube

Setting up the development environment of Node.js.

Node.js is a platform built on Chromes JavaScript runtime for easily building fast and scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices
9-Jun-2021 /3 /129