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. Introduction 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. 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 p...
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. Initializing the working directory: Open a suitable text editor of your choice. I will use VS Code for the whole series of Node.js to learn Node.js. From FILE , select OPEN FOLDER and select a working directory for your learning. The alternative to this is, right click on the desired working directory and select OPEN WITH CODE. After the working directory has opened we will have to initialize the directory for our Node.js activities. We do it by : >> npm init After that a series of questions are asked as shown in the following picture : We are asked package name, version, description, entry point, test command, git repository,keywords, author and license of our project. Don't worry. Here I have left it empty for ...