Articles tagged in: Node.js



Node.js — Read a JSON File

JSON (JavaScript Object Notation) is a data format used across applications to share data. The applications can use different languages and they are able to share information using the JSON format. Node.js and NPM use a JSON file storing configuration details: the package.json file. Besides the package.json …

Continue Reading

Node.js — Detect if Running on Windows

Sometimes it’s necessary to detect the operating system running the Node.js process. Node.js comes with the built-in os module providing methods to detect the current platform. Use the methods to create a utility function detecting whether you’re currently running Node.js on Windows. {{outline}} Check if …

Continue Reading

Node.js — Detect if Running on macOS

Sometimes you need to detect the platform that runs your Node.js process. You can do that by using Node.js’ built-in os module. It provides a method returning the operating system and you can then compare the platform against macOS. {{outline}} Check if the Operating System is macOS The …

Continue Reading

Node.js — Detect if Running on Linux

In some situations, you need to detect the operating system running the Node.js process. You can do that by using Node.js’ built-in os module. {{outline}} Check if the Operating System is Linux The os module in Node.js provides a platform method. This platform method allows you to …

Continue Reading

Node.js — Get a File‘s Extension

In some situations, you may need to retrieve the extension of a file on your local disk. Node.js comes with built-in functionality that you can use in your application. This tutorial shows you how to retrieve the file extension in Node.js. {{outline}} Retrieve the File Extension Node.js’ …

Continue Reading

Node.js — Get the Size of a File

Node.js ships with the native fs module to interact with the local file system. The fs module supports retrieving statistics for a file on your local disk. You may also get the size of a file from these statistics. This tutorial shows you how to retrieve the file size …

Continue Reading

Explore the Library

Find interesting tutorials and solutions for your problems.