NodeJS without NPM

NodeJS without NPM

Implementing a Web framework in NodeJS without using NPM

Play this article

This article lists things that we can achieve in NodeJS without using any NPM dependencies. You can find the repository on GitHub β€” faizahmedfarooqui/nodejs.

Let's review things that we could developing using only low-level NodeJS APIs;


  • A server to listen to HTTP/HTTPS requests (View Code)
  • Deflate / GZIP Compression for HTTP/HTTPS created servers (View Code)
  • RESTful API to CRUD and many more for users, tokens & checks (View Code)
  • Router for request methods like GET, POST, PUT & DELETE (View Code)
  • Handlers(ie. controllers) to handle requests & their methods (View Code)
  • Model Base class (View Code)


  • A Worker to execute things in the background (View Code)


  • A logging logic that logs everything into a *.log file (View Code)

Compress & Decompress:

  • A gzip compression logic which compresses older log file (View Code)


  • Local debug environment for the developments in each file (View Code)

Serve Routes & Templates:

  • A use of template logic & data interpolation (View Code)

Serve Static Assets:

  • Logic to serve static assets to the web-app (View Code)
  • Web routes handler for serving pages & static assets (View Code)

CLI Tool with Input Handlers & their Responders:

  • The CLI tool that runs using node’s readline, events libraries & many more (View Code)
  • CLI Events handlers (View Code)
  • CLI Events responders (View Code)

Handling Error Crash:

  • Server request are handled using try-catch block & now rather than app crash send 500 error response (View Code)

Debugger Mode:

  • For detailed information, please use its official documentation from NodeJS.
  • To run the app in debugger mode, use command node inspect index-debug.js

Performance Hooks:

  • Added PerformanceObserver Node Class to observe all the entries & log them out to the CLI (View Code)
  • Added Performance Mark & Measure methods to measure all the marked performance steps (View Code)
  • To see how it works, run the command NODE_DEBUG=performance node index.js in your terminal


  • Added a new file with clusters, here forks are created by the count of the CPUs available (View Code)
  • To see how it works, run the command node index-cluster.js in your terminal

Child Process:

  • Using ls commands into the .logs folder from CLI commands list logs (View Code)

Other NodeJS Modules:

  • Use of Async Hooks module (View Code)
  • Use of HTTP/2 module in Client & Server Logic (View Code)
  • Use of NET module in Client & Server Logic (View Code)
  • Use of REPL module (View Code)
  • Use of TLS/SSL module in Client & Server Logic (View Code)
  • Use of UDP module in Client & Server Logic (View Code)
  • Use of VM module (View Code)

How to download & setup?

# You only need NodeJS (LTS) ie. >= 8.11.3

# Clone this repo using your terminal
git clone;

# Go inside the repo
cd nodejs;

# Make a data directory into the root of the project
mkdir .data && cd .data;

# Create 3 more directories into the .data directory
mkdir users checks tokens;

# Go back to project's root 
cd ..;

# Make a logs directory into the root of the project
mkdir .logs;

# Goto the https directory
cd https;

# Now run the command given also available 
# in the file keyGeneration.txt
openssl req -newkey rsa:2048 -new -nodes -x509 \ 
 -days 3650 -keyout key.pem -out cert.pem;

That's All!

# About Me πŸ‘¨β€πŸ’»

I'm Faiz A. Farooqui. Software Engineer from Bengaluru, India. Find out more about me @

Did you find this article valuable?

Support Faiz's Blog by becoming a sponsor. Any amount is appreciated!