Posted by admin at January 18, 2022
Visual Studio Code is a source-code editor made by Microsoft for Windows, Linux and macOS. Features include support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and embedded Git. Wikipedia General: Ctrl+Shift+P, F1 Show Command Palette Ctrl+P Quick Open, Go to File… Ctrl+Shift+N New window/instance Ctrl+Shift+W Close window/instance Ctrl+, […]
ContinuePosted by admin at March 20, 2020
Reading from files is done via the core fs module. There are two sets of reading methods: asynchronous (recommended) and synchronous. In most cases, developers should use async methods, such as fs.readFile because this method won’t block the event loop:const fs = require(‘fs’) const path = require(‘path’) fs.readFile(path.join(__dirname, ‘/data/customers.csv’), {encoding: ‘utf-8’}, function (error, data) { if (error) return console.error(error) […]
ContinuePosted by admin at
Node provides a built-in module mechanism which works with the require() method and the module.exports global object. To demonstrate how require and module.exports work, let’s say we have two files account-service.js and utility.js. The utility.js has some generic methods and objects which we use in many projects and applications. In this example, we will import those generic methods into account-service.js. Here’s the code of utility.js in which […]
ContinuePosted by admin at
This is the most common use case because it allows you to save long Node programs and run them. To run a Node.js script from a file, simply type node filename. For example, to launch code from a program.js file which is located in a current folder, simply execute node program.js The file must be in […]
ContinuePosted by admin at
Like most platforms/languages (e.g., Java, Python, Ruby, and PHP), Node.js comes with a virtual environment called Read-Evaluate-Print Loop (REPL). Using REPL (a.k.a. Node console), we can execute pretty much any Node.js/JavaScript code. It is even possible to include modules and work with the file system! To start Node REPL, run the following command in your […]
ContinuePosted by admin at January 28, 2020
Why Node.js? Let’s start by taking a look at why Node.js is one of the fastest growing web platforms out there. Node.js provides you with the following benefits: Develop faster due to the vast number of modules and reusable code from npm Make fewer mistakes and be more productive (One language across the stack) Delight […]
Continue