Can Modern Node.js Do That?

Can Modern Node.js Do That?

🌍 Introduction

Node.js has come a long way from being a simple runtime for running JavaScript on servers. Today’s Node.js (v20 → v22) is a full development ecosystem with features that rival modern frameworks and languages.

Modern Node.js now supports:

  • ✅ ES Modules (ESM)
  • ✅ Built-in Test Runner
  • ✅ Native Watch Mode
  • ✅ TypeScript support
  • ✅ Promise-based APIs for Timers & FS
  • ✅ Built-in .env file support
  • ✅ Embedded SQLite Database
  • ✅ Single Executable Applications
  • ✅ Permission Model for Security
  • ✅ Native fetch() and Web Streams

Let’s unpack all of these, with code examples and practical use cases.


⚙️ 1. Watch Mode — Auto-Restart on File Changes

Tired of restarting your Node server manually every time you edit code? Modern Node.js now supports a built-in Watch Mode — no need for nodemon!

Article content

When you save your file, Node automatically restarts the process.

Example:

Article content
Article content

🎯 Why it matters: Built-in developer convenience. No external packages, no configuration, instant feedback loop.


🧩 2. TypeScript — Official Support via Node v22

Node.js now natively supports TypeScript execution (via the --experimental-strip-types flag in Node v22). This means you can run .ts files directly — no build step, no ts-node.

Article content

Example:

Article content

Output:

Article content

🎯 Why it matters: TypeScript and Node finally work together out of the box. Ideal for prototyping and full projects alike.


🗃️ 3. SQLite — Built-in Database Support

Node.js v22+ introduces experimental support for SQLite, letting you work with lightweight relational databases without third-party packages like better-sqlite3.

Article content

🎯 Why it matters: Native database support = fewer dependencies and faster local data storage for CLI tools, testing, or small APIs.


⏱️ 4. Promise-Based Timers

You can now use Promises directly with setTimeout and setInterval — thanks to node:timers/promises.

Article content

🎯 Why it matters: Cleaner async syntax with await — no callbacks, no util.promisify() needed.


🔐 5. .env File Support

Node.js now supports loading environment variables from .env files without any external library like dotenv.

Just create a .env file:

Article content

Then load it automatically with:

Article content


Inside your app.js:

Article content

🎯 Why it matters: Zero-dependency environment management — faster, more secure, and consistent across environments.


🧪 6. Built-in Test Runner

Testing is now part of Node.js itself — using node:test.

Article content

Run tests:

Article content

🎯 Why it matters: Simplifies testing; no setup for Jest or Mocha needed for small/medium projects.


🧠 7. Permission Model — Secure Execution

Node v20 introduced the experimental permission model.

You can restrict what files, environment variables, or network requests your app can access.

Article content

Inside your code:

Article content

🎯 Why it matters: Brings sandbox-level security for scripts and CI pipelines.


💾 8. Single Executable Applications (SEA)

You can now bundle your Node.js project into a single binary executable — no need to install Node or dependencies on target machines.

Example configuration (sea-config.json):

Article content

Build:

Article content

🎯 Why it matters: Great for distributing CLI tools or apps where Node.js isn’t pre-installed.


🌐 9. Native Fetch API & Web Streams

You can now use the same fetch() and Response APIs in Node as you do in the browser.

Article content

🎯 Why it matters: Frontend and backend now share consistent APIs — easier full-stack development.


🧰 10. Watch, Test, Build — All in One

With all these updates, you can now build a lightweight full-stack or CLI app entirely with built-in Node.js features.

Example Project: Modern CLI

Article content

This runs your TypeScript CLI, auto-restarts on changes, loads .env variables, and executes built-in tests — all natively.


🔍 More Modern Node.js Capabilities You Should Know

Feature Description WASI (WebAssembly System Interface) Run WebAssembly modules natively inside Node Web Crypto API Built-in crypto.subtle for secure hashing/encryption AbortController Cancel ongoing requests or async tasks node:diagnostics_channel Low-level observability for logs & performance node:streams/web Aligns Node’s streaming API with browser ReadableStream V8 12.x Engine Brings better startup, GC, and performance for modern JS node:sqlite (experimental) Native SQLite support (no 3rd-party deps) Top-level await Use async/await in modules directly


🚀 Putting It All Together

Here’s how a modern Node.js full project could look today:

Article content

Run:

Article content

And you’ve got: ✅ TypeScript support ✅ Auto-reload ✅ .env variables ✅ Promise timers ✅ No build tools needed


🏁 Conclusion

Modern Node.js isn’t just for APIs anymore. It’s now a complete ecosystem that supports:

  • Native database access
  • Secure sandboxing
  • Real-time reloads
  • Native testing
  • TypeScript execution
  • Single-binary deployment

If you haven’t upgraded to Node 20+ yet, now’s the perfect time.


To view or add a comment, sign in

More articles by Abhijeet Dongre

Others also viewed

Explore content categories