New to backend JavaScript and wondering what exactly Node.js is doing behind the scenes? You are not alone. In countless forum threads, developers ask how Node runs JavaScript outside the browser, what the event loop actually does, and when to reach for workers or clustering.
I’m new to coding, and I’m learning JavaScript. What is the Node.js runtime for JavaScript? How does it differ from regular JS and how do I use it to build APIs or tools? I am also curious about how async I/O works, how concurrency is handled, and what the typical Node development workflow looks like.
Node.js is a JavaScript runtime that lets you execute JS outside the browser. It combines Google’s V8 engine for executing JavaScript with system-level libraries that provide non-blocking I/O and networking so you can build servers, CLIs, workers, and more.
- V8: Compiles and executes JavaScript efficiently.
- libuv: Provides the event loop and asynchronous I/O primitives for files, sockets, DNS, and timers.
- Standard library: Built-in modules like
fs,http,crypto,events,url, plusnode: prefixed imports. - Module systems: Supports ECMAScript modules (
import) and CommonJS (require). - Package ecosystem: npm, pnpm, or yarn manage dependencies and scripts via
package.json. - Non-blocking by default: Most I/O APIs return promises or accept callbacks so the main thread stays responsive.
The event loop schedules timers, handles I/O completion, and runs microtasks. This quick snippet shows ordering:
console.log('A');
setTimeout(() => console.log('B'), 0);
Promise.resolve().then(() => console.log('C'));
console.log('D');
// Output: A, D, C, Code language: JavaScript (javascript)
- No DOM or browser APIs like
documentorwindow. - Direct access to the file system, TCP sockets, and OS signals.
- Same language, different APIs. You can still share logic between client and server.
- Avoid blocking the event loop. Heavy CPU work should use worker threads or be offloaded to services.
- Parallelize I/O with async functions and
Promise.all. - Scale across cores using multiple processes behind a load balancer.
- Install Node LTS and a package manager (usually NPM).
- Initialize
package.json, add scripts, and write ESM modules. - Use environment variables for secrets, lint and test, then deploy to your host or serverless platform.
Many Node apps need to store, transform, and deliver images or videos. Understanding image hosting fundamentals helps you plan for caching, formats, and delivery. You can even check out our guide on uploading images in Node.js with Cloudinary.
You can implement transformations yourself, but most teams prefer a service that automates format negotiation, resizing, and compression. That frees your Node server to focus on business logic and reduces CPU load.
Cloudinary plugs into Node apps for uploads, on-the-fly image optimization, and fast delivery from a CDN. Below is a minimal example using the Node SDK to upload a local image and generate an optimized URL.
import { v2 as cloudinary } from 'cloudinary';
// Use environment variables in production
cloudinary.config({
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET
});
async function uploadAndGetUrl() {
const result = await cloudinary.uploader.upload('./assets/hero.jpg', {
folder: 'node-runtime-demo'
});
// Build a delivery URL that auto-picks format and quality and resizes to 800px width
const url = cloudinary.url(result.public_id, {
transformation: [
{ width: 800, crop: 'scale' },
{ fetch_format: 'auto', quality: 'auto' }
]
});
return url;
}
uploadAndGetUrl().then(console.log).catch(console.error);Code language: JavaScript (javascript)
This approach offloads image processing, yields smaller payloads, and lets you ship faster while maintaining quality across devices.
- Node.js is a JS runtime built on V8 and libuv that provides non-blocking I/O and a rich standard library.
- The event loop handles async tasks so your server stays responsive.
- Use async I/O for throughput, move CPU-heavy work off the main thread, and scale with multiple processes.
- PNG to WebP Converter
- Image Upscaling and Quality Enhancement
- WebM to MP4 Converter
- Video Engineering Guide
Ready to build fast, media-savvy Node apps? Create a free Cloudinary account and start optimizing images and videos in minutes.