Jump to content

Node.js

From Alfawiki
Node.js
Company typeOpen source software
IndustrySoftware development
Founded2009; 17 years ago (2009)
FounderRyan Dahl
Headquarters
Worldwide
Area served
Cross-platform
Key people
Ryan Dahl (creator), Isaac Schlueter, Timothy J. Fontaine
ProductsJavaScript runtime environment
OwnerOpenJS Foundation (under Linux Foundation)
Websitenodejs.org

Node.js Overview

Node.js is a cross-platform, open-source JavaScript runtime environment compatible with operating systems such as Windows, Linux, Unix, macOS, among others. It operates on the V8 JavaScript engine, enabling the execution of JavaScript code independently of a web browser.

This platform empowers developers to create CLI utilities and perform server-side scripting using JavaScript. Running JavaScript on the server side frequently facilitates the production of dynamic web page content prior to delivery to the client’s browser. As a result, Node.js embodies the "JavaScript everywhere" paradigm,[1] which unites web-application development under a single programming language instead of segregating server-side and client-side languages.

Node.js utilizes an event-driven architecture with support for asynchronous I/O. These architectural decisions are intended to enhance both throughput and scalability in applications that handle numerous input/output tasks, as well as in real-time Web scenarios such as real-time communication software and browser-based games.[2]

The development of Node.js was formerly overseen by the Node.js Foundation,[3] which has since merged with the JS Foundation to establish the OpenJS Foundation. This foundation operates under the umbrella of the Linux Foundation's Collaborative Projects initiative.[4]

History

File:Ryan Dahl.jpg
Ryan Dahl, the original creator of Node.js, pictured in 2010
File:Node.JS Mascot.svg
Rocket Turtle, the official Node.js mascot since February 2024

Node.js was developed by Ryan Dahl in 2009,[5] approximately thirteen years following the launch of the first server-side JavaScript platform, Netscape's LiveWire Pro Web.[6] Initially, it was compatible only with Linux and Mac OS X. Dahl spearheaded its development, which later received backing from Joyent.[7]

Dahl expressed concerns about the limitations of Apache HTTP Server in managing a large number (10,000+) of simultaneous connections and criticized the prevalent sequential programming model, which could block entire processes or require multiple execution threads for concurrent connections.[8]

The project was unveiled by Dahl at the first European JSConf event on November 8, 2009.[9] Node.js integrated Google's V8 JavaScript engine with an event loop and a low-level I/O API.[10]

In January 2010, the Node.js ecosystem expanded with the introduction of a package manager known as npm.[11] This tool enables developers to distribute and share Node.js packages and their source code, streamlining package installation, updates, and removal.[10]

By June 2011, Microsoft collaborated with Joyent to create a native Windows version of Node.js,[12] with the first Windows-compatible build released in July 2011.

Leadership transitioned in January 2012 when Dahl handed control over to Isaac Schlueter, the creator of npm.[13] Later, in January 2014, Schlueter announced Timothy J. Fontaine as the new project lead.[14]

In December 2014, Fedor Indutny launched io.js, a fork of Node.js driven by dissatisfaction with Joyent’s governance model. io.js adopted an open-governance approach featuring an independent technical committee aimed at fostering greater community involvement and faster integration of updates from Google’s V8 JavaScript engine compared to Node.js at that time.[15]

To unify efforts, the Node.js Foundation was established in February 2015 to merge Node.js and io.js under one organization.[16] This consolidation culminated in September 2015 with the release of Node v4.0, combining io.js v3.3 and Node.js v0.12.[17] The merger introduced V8’s ES6 capabilities into Node.js and initiated a long-term support strategy.[18] By 2016, io.js ceased further releases and encouraged users to transition back to Node.js, marking the end of the fork and confirming the success of the unification.[19]

In 2019, the JS Foundation merged with the Node.js Foundation to create the OpenJS Foundation.

Branding

The Node.js emblem consists of a green hexagon with intersecting bands, symbolizing the runtime's cross-platform capabilities. In February 2024, the Rocket Turtle was selected as the official mascot for Node.js following a design competition.

Overview

Node.js enables developers to create web servers and networking utilities using JavaScript alongside a suite of "modules" that provide essential core features. These modules cover functionalities such as file system input/output, networking protocols (DNS, HTTP, TCP, TLS/SSL, and UDP), handling binary data via buffers, cryptographic operations, data streams, and other fundamental operations. The API for these modules is crafted to simplify the process of developing server-side applications.

While JavaScript is the only language supported natively by Node.js, numerous compile-to-JS languages exist, allowing applications to be written in languages like CoffeeScript, Dart, TypeScript, and ClojureScript, among others.

Node.js is predominantly utilized for building network-oriented programs such as web servers. A key distinction from PHP lies in their handling of I/O operations: PHP functions generally operate in a blocking manner, executing commands sequentially after prior tasks complete. In contrast, Node.js employs non-blocking functions that run concurrently and rely on callbacks to indicate task completion or errors. This asynchronous model introduces new security considerations not typically present in conventional web server architectures.

Official support for Node.js extends across Linux, macOS, and Microsoft Windows versions 8.1 and Server 2012 onward. Additionally, Tier 2 support includes platforms like SmartOS and IBM AIX, with experimental compatibility for FreeBSD. It also runs on OpenBSD, and Long-Term Support (LTS) releases are available for IBM i (AS/400). The source code can be compiled on other similar systems lacking official support, such as NonStop OS and various Unix servers.

Platform architecture

Node.js facilitates the creation of high-performance web servers using JavaScript through an event-driven programming approach. Developers can build servers that scale efficiently without relying on threading, by employing a streamlined mechanism based on callbacks to indicate task completion. Node.js combines the simplicity of a scripting language like JavaScript with the robustness of Unix network programming.

Constructed atop Google's V8 JavaScript engine, Node.js was released as open-source software under the BSD license. It offers extensive support for essential protocols including HTTP, DNS, and TCP. The widespread adoption of JavaScript contributed to Node.js's appeal within the web development community.

Industry support

The Node.js ecosystem boasts thousands of open-source libraries, predominantly hosted on the npm platform. The community is actively engaged through numerous conferences and events such as NodeConf, Node Interactive, Node Summit, along with various regional gatherings.

To streamline application development, the open-source community has introduced several web frameworks like Express.js, Socket.IO, Sails.js, Next.js, and Meteor. Additionally, packages facilitating integration with other languages or runtime environments, including Microsoft .NET, have been developed.

Contemporary desktop IDEs offer specialized editing and debugging capabilities tailored for Node.js projects. Popular IDEs supporting Node.js include Atom, Brackets, JetBrains' WebStorm,Microsoft Visual Studio (enhanced by Node.js Tools for Visual Studio or TypeScript with Node typings),NetBeans, Nodeclipse Enide Studio (based on Eclipse), and Visual Studio Code. Moreover, several online IDEs such as Codeanywhere, Eclipse Che, Cloud9 IDE, and the visual flow editor in Node-RED also provide Node.js support.

Node.js enjoys compatibility with a variety of cloud hosting services including Jelastic, Google Cloud Platform, AWS Elastic Beanstalk, Azure Web Apps, and Joyent.

Releases

│Template:Version│o│21.x │Template:Version│o│End-of-Life │[21] │2023‑10‑17 │2024‑06‑01 │Template:Version│c│22.x │Template:Version│c│Active LTS │Jod [23][21] │2024‑04‑24 │2027‑04‑30 │Template:Version│o│23.x │Template:Version│o│End-of-Life │[21] │2024‑10‑15 │2025‑06‑01 │Template:Version│cp│24.x │Template:Version│cp│Current │Krypton [23] │2025‑04‑22 │2028‑04‑30 │Template:Version│p│26.x │Template:Version│p│Planned │Lithium[23] │2026 │2029 │Template:Version│p│28.x │Template:Version│p│Planned │Magnesium [23] │2027 │2030 │Template:Version│p│30.x │Template:Version│p│Planned │Neon[23] │2028 │2031 │Template:Version│p│32.x │Template:Version│p│Planned │Oxygen[23] │2029 │2032 │Template:Version│p│34.x │Template:Version│p│Planned │Platinum[23] │2030 │2033 colspan="5" style="font-size:small;" | Template:Version l show=111111
Release[20] Status Code name Release date Maintenance end
Template:Version Template:Version 2013-03-11 2016-10-31
Template:Version Template:Version 2015-02-06 2016-12-31
Template:Version Template:Version Argon[21] 2015-09-08 2018-04-30
Template:Version Template:Version 2015-10-29 2016-06-30
Template:Version Template:Version Boron[21] 2016-04-26 2019-04-30
Template:Version Template:Version 2016-10-25 2017-06-30
Template:Version Template:Version Carbon[21] 2017-05-30 2019-12-31
Template:Version Template:Version 2017-10-01 2018-06-30
Template:Version Template:Version Dubnium[21] 2018-04-24 2021-04-30
Template:Version Template:Version 2018-10-23 2019-06-01
Template:Version Template:Version Erbium[21] 2019-04-23 2022-04-30
Template:Version Template:Version 2019-10-22 2020-06-01
Template:Version Template:Version Fermium[21] 2020-04-21 2023-04-30
Template:Version Template:Version 2020-10-20 2021-06-01
Template:Version Template:Version Gallium[21] 2021-04-20 2023-09-11[22]
Template:Version Template:Version 2021-10-19 2022-06-01
Template:Version Template:Version Hydrogen[21] 2022-04-19 2025-04-30
Template:Version Template:Version 2022-10-18 2023-06-01
Template:Version │co│20.x
│Template:Version│co│Maintenance LTS 
│Iron[23] 
│2023‑04‑18 
│2026‑04‑30 

Node.js major versions are released biannually from the GitHub main branch, with even-numbered versions launched in April and odd-numbered ones in October. Upon release of a new odd-numbered version, the preceding even-numbered version enters Long-term support (LTS). This LTS phase provides one year of active maintenance starting from the LTS designation date, followed by an additional eighteen months dedicated to maintenance updates. During the active LTS period, non-breaking backports are applied shortly after their introduction in the current release, whereas maintenance mode restricts updates to critical bug fixes and documentation improvements.[21] The strategy and policy for LTS releases are overseen by the LTS Working Group in cooperation with the Node.js Foundation's Technical Steering Committee.

Technical details

Node.js functions as a JavaScript runtime environment that continuously processes incoming requests through a mechanism known as the event loop.

Internals

Underneath, Node.js utilizes libuv to manage asynchronous events. Libuv serves as an abstraction layer providing network and file system capabilities compatible with both Windows and POSIX-based platforms such as Linux, macOS, OSS on NonStop, and Unix. For HTTP functionality, Node.js depends on nghttp2. Starting with version 20, Node.js incorporates the ada library to ensure compliance with the latest WHATWG URL standards. Since version 19.5, the simdutf library has been employed to accelerate Unicode validation and transcoding processes. As of version 21.3, the simdjson library is used to enable rapid JSON parsing.

Threading

Node.js runs on a single-threaded event loop architecture, leveraging non-blocking I/O operations that enable it to manage tens of thousands of simultaneous connections without incurring the overhead of thread context switching. This single-thread design, which shares one thread among all requests following the observer pattern, is optimized for highly concurrent applications where any I/O operation must invoke a callback. To support this event loop model, Node.js employs the libuv library, which internally uses a fixed-size thread pool to perform certain asynchronous non-blocking I/O tasks.

Parallel task execution in Node.js is managed by this thread pool. The main thread dispatches tasks into a shared queue, from which worker threads retrieve and process them. Operations inherently non-blocking at the system level, like networking, utilize kernel-level non-blocking sockets, whereas blocking system calls such as file I/O are executed on dedicated threads within the pool. Upon task completion by a worker thread, it notifies the main thread, which then activates the corresponding callback function.

A limitation of this single-threaded model is that Node.js does not natively support vertical scaling by simply increasing the number of available CPU cores without additional tools like the cluster module,[24] StrongLoop Process Manager,Cite error: The opening <ref> tag is malformed or has a bad name or pm2.Cite error: The opening <ref> tag is malformed or has a bad name Nevertheless, it is possible for developers to adjust the size of the libuv thread pool beyond its default setting, allowing the underlying server operating system (OS) to allocate these threads across multiple CPU cores.Cite error: The opening <ref> tag is malformed or has a bad name Another challenge arises with long-running computations or CPU-intensive tasks, which block the event loop entirely until they finish execution.Template:Fix/category[citation needed]

V8

V8 is the JavaScript engine originally developed for Google Chrome and later made open source by Google in 2008. Constructed using C++, V8 performs just-in-time compilation by translating JavaScript code into native machine instructions during execution. Since 2016, it has incorporated Ignition, a bytecode interpreter.

Package management

The Node.js platform comes with npm pre-installed as its package manager. npm facilitates the installation and management of third-party Node.js modules by retrieving them from the npm registry.

Event loop

Node.js registers itself with the operating system to receive notifications about asynchronous I/O events such as incoming connections. Inside the Node.js runtime, events invoke callbacks, with each connection managed as a small heap allocation. Unlike traditional approaches that assign separate OS-level processes or threads for each connection, Node.js employs an event loop to handle concurrent I/O operations. Unlike other event-driven servers, Node.js does not require explicit invocation of the event loop; instead, callbacks are declared, and the event loop starts automatically after these definitions. The event loop terminates once there are no remaining callbacks to execute.

WebAssembly

Node.js supports WebAssembly, and beginning with version 14, it offers experimental compatibility with WASI, the WebAssembly System Interface.

Native bindings

Node.js enables the creation of native "add-ons" through a C-based API known as N-API, which allows developers to build loadable .node modules from C or C++ source code. These modules can be dynamically loaded and executed within the JavaScript environment as standard CommonJS modules. The N-API implementation depends on internal C/C++ objects from Node.js and V8, requiring developers to include Node.js-specific headers in their native code.

Because the Node.js API can undergo binary-level breaking changes, native modules must be compiled and distributed for specific Node.js versions to maintain compatibility. To mitigate this challenge, various open-source C/C++ wrapper libraries have been developed atop N-API, simplifying interface usage but potentially adding complexity for maintainers. While core Node.js functionality resides in its JavaScript standard library, native C++ modules can be leveraged to extend features and enhance application performance.

Creating such modules necessitates an appropriate C++ compiler and access to required headers (usually bundled with Node.js), such as gcc, clang, or MSVC++.

N-API bears resemblance to the Java Native Interface.

Project governance

Starting in 2015, multiple segments of the broader Node.js community united under the impartial Node.js Foundation. The foundation's mission is to promote broad adoption and accelerate the advancement of Node.js along with associated modules by implementing an open governance structure that fosters engagement, technical contributions, and a sustainable management framework supported by a community dedicated to Node.js' ongoing success.

The Node.js Foundation's Technical Steering Committee (TSC) serves as the primary technical leadership entity. This committee oversees the core Node.js repository as well as related and dependent projects. Typically, the TSC entrusts project management responsibilities to specialized working groups or committees. One such group is the LTS team, which handles long-term support releases. Additional active groups include Website, Streams, Build, Diagnostics, i18n, Evangelism, Docker, Addon API, Benchmarking, Post-mortem, Intl, Documentation, and Testing.

In August 2017, approximately one-third of the TSC members stepped down following disagreements concerning the project's code of conduct.

Current TSC Members[25]
Username Full Name
aduh95 Antoine du Hamel
anonrig Yagiz Nizipli
benjamingr Benjamin Gruenbaum
BridgeAR Ruben Bridgewater
gireeshpunathil Gireesh Punathil
jasnell James M Snell
joyeecheung Joyee Cheung
legendecas Chengzhong Wu
marco-ippolito Marco Ippolito
mcollina Matteo Collina
mhdawson Michael Dawson
RafaelGSS Rafael Gonzaga
richardlau Richard Lau
ronag Robert Nagy
ruyadorno Ruy Adorno
ShogunPanda Paolo Insogna
targos Michaël Zasso
tniessen Tobias Nießen

External links

  • Official website
  1. ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
  2. ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
  3. ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
  4. ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
  5. ↑ Cite error: Invalid <ref> tag; no text was provided for refs named training.com
  6. ↑ ...
  7. ↑ Cite error: Invalid <ref> tag; no text was provided for refs named Google Groups post by Ryan Dahl about Joyent
  8. ↑ ...
  9. ↑ Cite error: Invalid <ref> tag; no text was provided for refs named b3
  10. ↑ 10.0 10.1 Cite error: Invalid <ref> tag; no text was provided for refs named b1
  11. ↑ ...
  12. ↑ ...
  13. ↑ ...
  14. ↑ ...
  15. ↑ Cite error: Invalid <ref> tag; no text was provided for refs named iwtw
  16. ↑ ...
  17. ↑ ...
  18. ↑ ...
  19. ↑ ...
  20. ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
  21. ↑ 21.00 21.01 21.02 21.03 21.04 21.05 21.06 21.07 21.08 21.09 21.10 21.11 Template:Cite web │url=https://github.com/nodejs/Release │title=nodejs/Release │website=GitHub │language=en │access-date=2018‑05‑03
  22. ↑ Bringing forward the End-of-Life Date for Node.js 16, Node.js Website
  23. ↑ 23.0 23.1 23.2 23.3 23.4 23.5 23.6 23.7 Template:Cite web │title=Node.JS CODENAMES.md │url=https://github.com/nodejs/Release/blob/main/CODENAMES.md │access-date=6 September │website=GitHub │language=en
  24. ↑ Cite error: Invalid <ref> tag; no text was provided for refs named node_cluster_module_doc
  25. ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).