NODE.JS INTRODUCTION
Node.js is an open-source, cross-platform JavaScript runtime environment built on Chrome's V8 JavaScript engine. It allows JavaScript to run outside a web browser, enabling server-side development and creation of scalable network applications.
Node.js was developed by Ryan Dahl in 2009 using the V8 JavaScript engine to solve concurrency issues and manage web traffic efficiently. It is a server-side environment matching the client-server architecture.
Node.js is highly scalable, bridges the gap between client and server, supports JavaScript reusability, and is easy to install, configure, and deploy.
FEATURES OF NODE.JS
Asynchronous & Non-blocking I/O
Node.js uses an event-driven, non-blocking I/O model, allowing efficient concurrent request handling without waiting for operations to complete. This is achieved using the event loop.
Single-threaded
Node.js runs on a single thread, but the event loop manages multiple operations by offloading I/O tasks to the system kernel.
npm (Node Package Manager)
Node.js includes npm, a large ecosystem of open-source libraries and tools that simplify development and extend functionality.
Use Cases
Node.js is ideal for building REST APIs, real-time applications (chat apps), microservices, and data-intensive applications.
WHAT NODE.JS IS USED FOR?
Node.js can be used for:
- Web Services APIs – such as REST (Representational State Transfer) for building scalable, flexible, and maintainable web services.
- Real-time multiplayer games.
- Backend web services – including cross-domain and server-side requests using CORS (Cross-Origin Resource Sharing).
- Web-based applications.
- Multi-client communication.
WHO USES NODE.JS
Large-scale consumer applications
Netflix, PayPal, LinkedIn, Uber, eBay, Walmart, Medium use Node.js for backend systems, real-time features, and API development.
Technology and software companies
GoDaddy, Trello, Yahoo, Mozilla, Capital One use Node.js for tools, service management, and internal applications.
Government and research institutions
NASA uses Node.js for data processing and real-time data stream management.
Financial institutions
Citibank, Morgan Stanley use Node.js for secure and efficient financial applications.
Other notable users
Groupon, Yandex, imgur, DuckDuckGo, Coursera use Node.js for web development, APIs, real-time apps, and data processing.
NODE.JS BUILT-IN MODULES
Node.js has built-in modules (core modules) that provide essential functions without external installation. These are pre-compiled in the Node.js binary and accessed using require() function.
Commonly used built-in modules:
- fs (File System) – Read, write, and manage files and directories.
- http – Create HTTP servers and clients, handle requests and responses.
- path – Work with file and directory paths (join, resolve, normalize).
- os – Get OS details like platform, CPU info, and network interfaces.
- events – Create and handle custom events using EventEmitter.
- url – Parse and format URLs.
- util – Utility functions for formatting, debugging, and inheritance.
- stream – Handle data streams for reading/writing large data efficiently.
- crypto – Provide cryptographic features like hashing, encryption, decryption.
These modules are essential for building web servers, command-line tools, and data processing scripts in Node.js.
References:
Mam send PPT unit 2