<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Devjeet Roy</title>
    <description>The latest articles on DEV Community by Devjeet Roy (@devjeetroy98).</description>
    <link>https://dev.to/devjeetroy98</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F307259%2Fe50033e4-0a70-4ada-b921-8068b3c7e4c7.jpeg</url>
      <title>DEV Community: Devjeet Roy</title>
      <link>https://dev.to/devjeetroy98</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/devjeetroy98"/>
    <language>en</language>
    <item>
      <title>The "fs" module in Node.js</title>
      <dc:creator>Devjeet Roy</dc:creator>
      <pubDate>Mon, 17 Aug 2026 05:34:41 +0000</pubDate>
      <link>https://dev.to/devjeetroy98/the-fs-module-in-nodejs-2hmb</link>
      <guid>https://dev.to/devjeetroy98/the-fs-module-in-nodejs-2hmb</guid>
      <description>&lt;p&gt;Hello my lovely audience on the internet! Today we will move ahead and learn about “fs” module in Nodejs. We will understand this “fs” module, how to use it inside Nodejs with some code samples. This post will be long so please stay tuned and let's code together.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If you have some knowledge of working with frontend development or at least you have written some JavaScript code in the browser, you know that the browsers are heavily sandboxed. When you visit a website, you are actually running untrusted code written by strangers and so to prevent your computer from any unwanted peril, browsers are designed to run JavaScript code inside a strict sandbox. Due to this, you can’t simply open a user’s Desktop / Documents folder and start reading their documents.&lt;/p&gt;

&lt;p&gt;But Node.js runs on the same Google Chrome’s V8 engine which is responsible for parsing the same JavaScript code. So, using Node.js can you read or write in a document? You might think “No”, but actually this is possible. And in this regard, the “file system” module or “fs” module comes to our rescue. This core module of Node.js gives it the superpower to read, write, update or delete files and folders which exists in our local system or server.&lt;/p&gt;

&lt;p&gt;Are you interested to learn how the magic happens? Let’s install Node.js if not done already and learn it together with some real-world examples. As for this example, I am using Node.js v24.19.0.&lt;/p&gt;

&lt;h2&gt;
  
  
  - Reading a file using filesystem module
&lt;/h2&gt;

&lt;p&gt;Reading a document is a very important feature when it comes to backend development or server-side development. By reading a document, you can fetch the content of the document which can be processed later to produce some desired output.&lt;/p&gt;

&lt;p&gt;While working with “fs” module you will come across two different variations of the implementation. The difference comes down to the style of asynchronous control flow the variations provide. In the “node:fs” variant of the “fs” module, you get synchronous and callback-based methods whereas in the “node:fs/promises”, you use asynchronous methods that return promises.&lt;/p&gt;

&lt;p&gt;In the Node.js documentation, using the “node:fs/promises” is recommended for modern application development because it seamlessly integrates with async/await and eliminates the overuse of nested callbacks also known as “callback hell.”&lt;/p&gt;

&lt;p&gt;Only for this example, we will see how to read a document using both methods but from the next example, we will be only using what the documentation recommends, the “promise” variant.&lt;/p&gt;

&lt;p&gt;Example 1: The "node.fs" variant&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyxeaf459vuzit2f5orr1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyxeaf459vuzit2f5orr1.png" alt="reading a file in nodejs" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Exampe 2: The "node:fs/promises" variant&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6a90l4d1bqfdln85q4zv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6a90l4d1bqfdln85q4zv.png" alt="promise api way of reading a file in nodejs" width="799" height="458"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the first example, first we import the required module “node:fs”. Then we use its “readFile” method to read the document “book.txt”. In the method, we also specify the character encoding “utf-8”. Then we assign a callback to the method. The callback method takes 2 arguments, “err” which is the error object and “data” which is the decoded data object which contains the contents of “book.txt” in simple plain English. If there is any error, we log the error on the console and return. In case, there is not error and data is found, we log it on the console.&lt;/p&gt;

&lt;p&gt;As for the second example, we use the “promise” version of the “fs” module. Here, we first import “node:fs/promises”. Then we declare an asynchronous method “readFile” to read the text file and return data. Rest of the code is pretty same as that of the first example. One thing to note here is, always wrap the file operations in a “try-catch” block. In case an error is thrown, the “catch” block can get it and handle it gracefully.&lt;/p&gt;

&lt;p&gt;Output (same for both):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9bxfunww1xw1gdtayvbv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9bxfunww1xw1gdtayvbv.png" alt="Code output for reading a file using fs module" width="800" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As mentioned already, the output for both the code is same. But it is preferrable to go with the "promises" version of the filesystem module.&lt;/p&gt;

&lt;p&gt;There are many such functions which the filesystem module can do. Some of the most popular functions along with their brief explanations are discussed in details in an article which I have written here: &lt;a href="https://learnnodeonline.blogspot.com/2026/08/the-file-system-fs-module-in-nodejs.html" rel="noopener noreferrer"&gt;https://learnnodeonline.blogspot.com/2026/08/the-file-system-fs-module-in-nodejs.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you like the article, please leave your feedback below.&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>module</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Online Tutor</title>
      <dc:creator>Devjeet Roy</dc:creator>
      <pubDate>Fri, 31 Jan 2020 07:44:58 +0000</pubDate>
      <link>https://dev.to/devjeetroy98/online-tutor-1d34</link>
      <guid>https://dev.to/devjeetroy98/online-tutor-1d34</guid>
      <description>&lt;p&gt;I am an Online Tutor who have 2 years of teaching experience in C, C++, Java, JavaScript and Python. I teach 1:1 ratio, where I personally teach a single student for a period of 1-2 months. Course fees is exceptionally low and you get study materials &amp;amp; Certificate if you intend to take.&lt;br&gt;
Languages : C,C++,Java, JavaScript &amp;amp; Python .&lt;br&gt;
Genre: Web Development using HTML,CSS,JS,jQuery,Bootstrap,Node.js &amp;amp; MongoDB.&lt;br&gt;
I am also a blogger. Visit : &lt;a href="https://learnnodeonline.blogspot.com/"&gt;Click Here&lt;/a&gt;&lt;br&gt;
If you are interested to learn from me, mail me : &lt;a href="mailto:devjeetroy.dr@gmail.com"&gt;devjeetroy.dr@gmail.com&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Node.js Modules</title>
      <dc:creator>Devjeet Roy</dc:creator>
      <pubDate>Fri, 17 Jan 2020 17:20:06 +0000</pubDate>
      <link>https://dev.to/devjeetroy98/node-js-modules-4mj1</link>
      <guid>https://dev.to/devjeetroy98/node-js-modules-4mj1</guid>
      <description>&lt;p&gt;Hello Folks! Today we will will move ahead and learn node.js more. We are going to write our first code in node.js today. Then we will discuss about modules in node.js. This post will be long so please stay tuned and let's code together.&lt;br&gt;
Initializing the working directory:&lt;br&gt;
Open a suitable text editor of your choice. I will use VS Code for the whole series of Node.js to learn Node.js.&lt;br&gt;
From FILE, select OPEN FOLDER and select a working directory for your learning.&lt;br&gt;
The alternative to this is, right click on the desired working directory and select OPEN WITH CODE.&lt;br&gt;
After the working directory has opened we will have to initialize the directory for our Node.js activities.&lt;br&gt;
To learn more visit : &lt;a href="https://learnnodeonline.blogspot.com/2020/01/node.js-modules.html"&gt;Click here&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What is the use of package.json?</title>
      <dc:creator>Devjeet Roy</dc:creator>
      <pubDate>Wed, 15 Jan 2020 17:59:53 +0000</pubDate>
      <link>https://dev.to/devjeetroy98/what-is-the-use-of-package-json-20ie</link>
      <guid>https://dev.to/devjeetroy98/what-is-the-use-of-package-json-20ie</guid>
      <description>&lt;p&gt;package.json is a JSON text file that contains the metadata of your project. It contains all the properties to identify the project such as it's name, current version of the module, license, author of the project, it's description etc. It also contains a list of all the dependencies which are used in the project.&lt;br&gt;
JSON stands for JavaScript Object Notation. It is highly used for transmitting data from server to web application. Many document based database stores data in this format.&lt;/p&gt;

&lt;p&gt;package.json is an indispensable part of the Node.js setup! It is written in JSON format.&lt;/p&gt;

&lt;p&gt;This file is created automatically when we initialize our node.js working directory by :&lt;/p&gt;

&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;npm init&lt;/p&gt;
&lt;/blockquote&gt;


&lt;/blockquote&gt;

&lt;p&gt;When we download any module to work in Node.js by :&lt;/p&gt;

&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;npm install  —save&lt;/p&gt;
&lt;/blockquote&gt;


&lt;/blockquote&gt;

&lt;p&gt;it gets saved in the package.json file under the dependencies, as the first picture suggests. The modules itself gets downloaded in the node_modules folder.&lt;/p&gt;

&lt;p&gt;When we send the project to someone, we don’t send the node_modules folder. We don’t even upload it to github by putting it in .gitignore file. When the user downloads our folder, he downloads automatically all the modules used in our project by :&lt;/p&gt;

&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;npm install&lt;/p&gt;
&lt;/blockquote&gt;


&lt;/blockquote&gt;

&lt;p&gt;Now, from where the user gets all the list of modules ??&lt;/p&gt;

&lt;p&gt;From the package.json file under the dependencies and the source url from package-lock.json!&lt;br&gt;
If you are a node.js enthusiasts follow my blog :&lt;br&gt;
&lt;a href="https://learnnodeonline.blogspot.com/"&gt;LEARNNODEONLINE.BLOGSPOT.COM | A PLATFORM TO LEARN NODE.JS&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to download and install Node.js</title>
      <dc:creator>Devjeet Roy</dc:creator>
      <pubDate>Tue, 07 Jan 2020 13:06:35 +0000</pubDate>
      <link>https://dev.to/devjeetroy98/how-to-download-and-install-node-js-4g2g</link>
      <guid>https://dev.to/devjeetroy98/how-to-download-and-install-node-js-4g2g</guid>
      <description>&lt;p&gt;Installing Node.js is a very easy but lengthy procedure.&lt;/p&gt;

&lt;p&gt;First visit the website : Node.js . See, by default as my PC has Windows 8.1 and it has 64 bit architecture so I can download from here.&lt;br&gt;
Major Node. js versions enter Current release status for six months, which helps library authors time to contribute. LTS release status is "long-term support", which generally guarantees that bugs will be fixed for a total of 30 months.&lt;/p&gt;

&lt;p&gt;But if you want to download some other binary files of node.js, click on the "DOWNLOADS" tab, from the top navigation bar of the website. As you can see, you have plenty of options and OS types to download for. For me, I have downloaded the Windows Installer(.msi) 64-bit architecture.&lt;/p&gt;

&lt;p&gt;If you are interested to download Node.js and install Node.js error free, visit my blog and read : &lt;a href="https://learnnodeonline.blogspot.com/2020/01/how-to-download-node.js.html"&gt;How to download node.js and configure your PC&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here I have explained everything step by step with pictures., from visiting the official website up to testing if the installation is error free. I hope the beginners will love it.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Node.js v/s Spring for startups</title>
      <dc:creator>Devjeet Roy</dc:creator>
      <pubDate>Fri, 03 Jan 2020 17:07:18 +0000</pubDate>
      <link>https://dev.to/devjeetroy98/node-js-v-s-spring-for-startups-25p8</link>
      <guid>https://dev.to/devjeetroy98/node-js-v-s-spring-for-startups-25p8</guid>
      <description>&lt;p&gt;Firstly, if you are like me, coming from a C, C++ background and then switched over to JavaScript for Front-end web development with very little or almost no knowledge in Java, Node.js should be your choice. But if you are well versed with Java, you may pick as you are comfortable with.&lt;/p&gt;

&lt;p&gt;Secondly, Node.js is single threaded. If something goes wrong and Node.js crashes, then everything crashes. You don’t have the isolation that you have with a Java web application.&lt;/p&gt;

&lt;p&gt;Thirdly, Spring Boot is fabulous: light and fast, complete and extremely configurable. Spring Boot strictly follows the MVC pattern. But in case of Express.js (minimalist framework for Node.js) it may or may not be configured like that way. So, if you mess up the codes its a problem.&lt;/p&gt;

&lt;p&gt;Fourthly, authentication in Spring is better as compared to Passport.js used with Node.js. But Passport.js supports major functions of Spring authentication and are sometimes simpler to code and understand the logic. Hibernate is still the most complete, mature, and versatile solution, but at a very high cost! Sequelize may cover 90% of your use cases. Sequelize is easy to create queries at runtime. Try to do it while creating a JPQL query or consider how over-complicated it is to do with certain criteria. Sequelize is a better option as per me.&lt;/p&gt;

&lt;p&gt;Lastly, as we are talking about startups, I will consider simplicity and flexibility over strict MVC and robustness of Spring. JS makes things much simpler and easy to code. Besides, the workflow in Node.js is much faster then that in Spring. Even, the learning curve is also smooth in Node.js as compared to Java. Rather then this build management is much tougher with Maven than with NPM.&lt;/p&gt;

&lt;p&gt;BONUS : According to Stack overflow survey, Express is before Spring both in terms of most loved and most wanted web frameworks. Even with Node.js you can code JavaScript at both ends of the website. But, Spring has been in market for long and has a large ecosystem supporting it. The number of high quality third-party libraries available in Java is very high.&lt;/p&gt;

&lt;p&gt;So at the end of the day, it is a matter of choice.&lt;/p&gt;

&lt;p&gt;Even feel free to visit my blog : &lt;a href="http://learnnodeonline.blogspot.com/"&gt;LEARNNODEONLINE.BLOGSPOT.COM | A PLATFORM TO LEARN NODE.JS&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Introduction to Node.js</title>
      <dc:creator>Devjeet Roy</dc:creator>
      <pubDate>Fri, 03 Jan 2020 12:11:03 +0000</pubDate>
      <link>https://dev.to/devjeetroy98/introduction-to-node-js-2pe3</link>
      <guid>https://dev.to/devjeetroy98/introduction-to-node-js-2pe3</guid>
      <description>&lt;p&gt;Introduction:&lt;/p&gt;

&lt;p&gt;As per the Node.js official documentation, Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. Before you mess up with the terms used here, let me explain what the official definition actually means by breaking it into small parts. When we run a JavaScript code or work with any JavaScript frameworks, the code gets executed in the browser. So, in that case our browser is the JavaScript runtime.  The JavaScript(JS) code is converted into machine code with the help of a JavaScript parser. In case of Google Chrome, it's V8, for Firefox it's SpiderMonkey and for Microsoft Edge it's Chakra. There are couples of libraries on which Node.js depends to work properly.&lt;br&gt;
Most important are: Chrome's V8 &amp;amp; LIBUV.&lt;br&gt;
If V8 was not there then Node.js had no way to understand, the JS code we write in the Node.js environment. LIBUV is an opensource library with strong focus on asynchronous I/O. this gives access to OS, file system, networking and more. This is also responsible for 2 main features of Node.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Event Loop.&lt;/li&gt;
&lt;li&gt;The Thread Pool.
Apart from all of this, Node.js also depends on:&lt;/li&gt;
&lt;li&gt;http-parser for parsing http.&lt;/li&gt;
&lt;li&gt;c-ares for some DNS request staff.&lt;/li&gt;
&lt;li&gt;OpenSSL for cryptography.&lt;/li&gt;
&lt;li&gt;zlib for compression.
We will discuss all of the above points in the upcoming posts. But let us first focus on the primary idea.
In simple words, Node.js lets developers use JavaScript to write command line tools and for server-side scripting-running scripts server-side to produce dynamic web page content before the page is sent to the user's web browser.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Characteristics of Node.js:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fast, efficient and highly scalable.&lt;/li&gt;
&lt;li&gt;Event driven, non-blocking I/O Model.&lt;/li&gt;
&lt;li&gt;Asynchronous in nature.&lt;/li&gt;
&lt;li&gt;Single Threaded.&lt;/li&gt;
&lt;li&gt;It's Open Source.&lt;/li&gt;
&lt;li&gt;We use only one language at both ends of the website.
To read more visit : &lt;a href="https://learnnodeonline.blogspot.com/"&gt;https://learnnodeonline.blogspot.com/&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>The Thread Pool in node.js </title>
      <dc:creator>Devjeet Roy</dc:creator>
      <pubDate>Fri, 03 Jan 2020 11:52:46 +0000</pubDate>
      <link>https://dev.to/devjeetroy98/the-thread-pool-in-node-js-1dbl</link>
      <guid>https://dev.to/devjeetroy98/the-thread-pool-in-node-js-1dbl</guid>
      <description>&lt;p&gt;When we run Node.js in our computer, it's a process which runs in our computer.The process is nothing but an executing program which gets executed in our local computer. When such a process runs, it runs in single thread. Thread is nothing but a sequence of instructions, which are dedicated to perform a given task. But let us remember that as Node.js runs on single thread we must try not to block the thread, no matter how many users or clients access our web application.&lt;br&gt;
When a program is initialized, all the code gets executed apart from the codes , which are inside any callback functions. All the necessary modules are required and the callbacks are registered. Thereafter, the event loop starts running. Thought this event loop will be discussed after this, but for now keep in mind that the "Event-Loop" is the heart of the entire Node.js architecture. It is responsible for major tasks performed in our application.&lt;br&gt;
But sometimes, the tasks are too heavy to be performed by the main thread of Node.js instantly and it then tends to block the execution. The solution to this is the "Thread Pool". It is basically a set of 4 additional threads provided by the LIBUV library. When a heavy task appears, the main thread offloads it to the additional threads to execute it. The heavy tasks like dealing with file system API, compression, cryptography and DNS lookups are offloaded generally. All of these are handled by Node alone. I hope now you have a little idea about the Thread Pool.&lt;br&gt;
&lt;a href="https://learnnodeonline.blogspot.com/"&gt;https://learnnodeonline.blogspot.com/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
