How to resize images using Node.js

June 10, 2020 A Goodman

Resizing images in Node.js is super easy with a library named gm. To use this one, you need to install ImageMagick first. Here is the download page for Windows, Linux, and macOS. After installing ImageMagick, open…

Using Axios to download images and videos in Node.js

April 8, 2021 A Goodman

Node.js is an asynchronous event-driven Javascript runtime that is designed to build scalable network applications. When handling files (from small images to large videos) with Node.js, you are free from the worries of dead-lock the process…

Check computer RAM size with Node.js

March 20, 2021 A Goodman

The built-in os module in Node provides methods that help you check your memory size. Note that 1 MB = 1024 KBs and 1KB = 1024 byte.

Get the number of CPU cores in Node.js

May 28, 2020 A Goodman

Node has a built-in module called os that can help you find out how many cores your CPU has. Example:

Excluding node_modules when using tree command on Mac

May 28, 2020 A Goodman

The node_modules folder is often super big and contains countless files and subdirectories. Therefore, when using the tree command to display your project structure, you should ignore node_modules. To do so, try this: The result: If…

Express: Automatically download an image when clicking a link

February 21, 2021 A Goodman

The simple project below will show you how to automatically download an image served from Express server when clicking a link. Our project structure: The code in app.js (don’t forget to install express before running your…

Node.js: 2 Ways to Colorize Console Log Output

April 21, 2021 A Goodman

By default, when you print something by using console.log() in Node.js, the output is usually white if your terminal has a dark background color or black if your terminal has a light background color. If you…

A few examples of exports and require in Node.js

February 10, 2020 A Goodman

A few easy-to-understand examples below will help you understand “exports” and “require” in Node.js better. Example 1 Exports (file your-file.js): Require (file index.js) Examples 2 Export (call it your-file.js or whatever you like): Require:

How to get all Links from a Webpage using Node.js and Cheerio

January 22, 2021 A Goodman

Node.js is a javascript runtime environment that helps you create high-performance apps. Because Node.js functions are non-blocking (commands execute concurrently or even in parallel, it can perform large tasks without incurring the cost of thread context…

1 2