Tips & Tutorials – Node JS

How To Move & Copy Files In NodeJS (Simple Examples)

Welcome to a tutorial on how to move and copy files in NodeJS. Need to back up some files in NodeJS? Move some old files to another folder? To copy a file in NodeJS – require(“fs”).copyFileSync(“SOURCE”, “TARGET”) To move a file in NodeJS – require(“fs”).renameSync(“SOURCE”, “TARGET”) That covers the quick basics, but read on if …

How To Move & Copy Files In NodeJS (Simple Examples) Read More »

How To Check NodeJS Version (Command Line & Runtime)

Welcome to a quick tutorial on how to check the NodeJS version. Need to check the current version of your Node installation? Or check if users meet the basic version requirement? To check the NodeJS version in the command line, run node -v. To get the NodeJS version during runtime – console.log(process.version); That covers the …

How To Check NodeJS Version (Command Line & Runtime) Read More »

Write Files In NodeJS (Very Simple Examples)

Welcome to a quick tutorial and examples on how to write files in NodeJS. Want to create, write, and append to files in NodeJS? Things are a little bit confusing for beginners in NodeJS. There are 2 general ways to write files in NodeJS – Asynchronous and synchronous. To write files asynchronously: require(“fs”).writeFile(“MY.TXT”, “TEXT”); require(“fs”).appendFile(“MY.TXT”, …

Write Files In NodeJS (Very Simple Examples) Read More »

5 Ways To Read Files In NodeJS (To String, Line-by-Line, Array)

Welcome to a quick tutorial and examples on how to read files in NodeJS. Reading files, just how difficult can it be? Well, brace yourselves. It’s not that straightforward apparently. The common ways to read files in NodeJS are: To read the entire file into a string asynchronously – require(“fs”).readFile(“FILE.TXT”, “utf8”, (err, data) => { …

5 Ways To Read Files In NodeJS (To String, Line-by-Line, Array) Read More »