Node.js is an
open-source
Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized sof ...
server environment. Node.js is
cross-platform
In computing, cross-platform software (also called multi-platform software, platform-agnostic software, or platform-independent software) is computer software that is designed to work in several computing platforms. Some cross-platform software r ...
and runs on Windows, Linux, Unix, and macOS. Node.js is a
back-end JavaScript
JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
runtime environment
In computer programming, a runtime system or runtime environment is a sub-system that exists both in the computer where a program is created, as well as in the computers where the program is intended to be run. The name comes from the compile t ...
. Node.js runs on the
V8 JavaScript Engine
A JavaScript engine is a software component that executes JavaScript code. The first JavaScript engines were mere interpreters, but all relevant modern engines use just-in-time compilation for improved performance.
JavaScript engines are typica ...
and executes JavaScript code outside a
web browser
A web browser is application software for accessing websites. When a user requests a web page from a particular website, the browser retrieves its files from a web server and then displays the page on the user's screen. Browsers are used on ...
.
Node.js lets developers use JavaScript to write command line tools and for
server-side scripting
Server-side scripting is a technique used in web development which involves employing scripts on a web server which produces a response customized for each user's (client's) request to the website. The alternative is for the web server itself ...
. The functionality of running scripts server-side produces
dynamic web page
A server-side dynamic web page is a web page whose construction is controlled by an application server processing server-side scripts. In server-side scripting, parameters determine how the assembly of every new web page proceeds, and includin ...
content before the page is sent to the user's web browser. Consequently, Node.js represents a "JavaScript everywhere" paradigm, unifying
web-application
A web application (or web app) is application software that is accessed using a web browser. Web applications are delivered on the World Wide Web to users with an active network connection.
History
In earlier computing models like client-serve ...
development around a single programming language, rather than different languages for server-side and client-side scripts.
Node.js has an
event-driven architecture Event-driven architecture (EDA) is a software architecture paradigm promoting the production, detection, consumption of, and reaction to events.
Overview
An ''event'' can be defined as "a significant change in state". For example, when a consumer p ...
capable of
asynchronous I/O
In computer science, asynchronous I/O (also non-sequential I/O) is a form of input/output processing that permits other processing to continue before the transmission has finished. A name used for asynchronous I/O in the Windows API is overlappe ...
. These design choices aim to optimize
throughput
Network throughput (or just throughput, when in context) refers to the rate of message delivery over a communication channel, such as Ethernet or packet radio, in a communication network. The data that these messages contain may be delivered ov ...
and
scalability
Scalability is the property of a system to handle a growing amount of work by adding resources to the system.
In an economic context, a scalable business model implies that a company can increase sales given increased resources. For example, a ...
in web applications with many input/output operations, as well as for
real-time Web
The real-time web is a computer network, network web using technologies and practices that enable users to receive information as soon as it is published by its authors, rather than requiring that they or their software check a source periodicall ...
applications (e.g.,
real-time communication
Real-time communication (RTC) is a category of software protocols and communication hardware media that gives real-time guarantees, which is necessary to support real-time guarantees of real-time computing.Sharad Sundaresan; Riccardo Bettati"Distr ...
programs and
browser game
A browser game or a "flash game" is a video game that is played via the internet using a web browser. They are mostly free-to-play and can be single-player or multiplayer.
Some browser games are also available as mobile apps, PC games, or on c ...
s).
The Node.js
distributed development
A distributed development project is a research and development (R&D) project that is done across multiple business worksites or locations. It is a form of R&D where the project members may not see each other face to face, but they are all worki ...
project was previously governed by the Node.js Foundation, and has now merged with the
JS Foundation
The OpenJS Foundation is an organization that was founded in 2019 from a merger of JS Foundation and Node.js Foundation. OpenJS Promotes the JavaScript and web ecosystem by hosting projects and funds activities that benefit the ecosystem. The OpenJ ...
to form the
OpenJS Foundation
The OpenJS Foundation is an organization that was founded in 2019 from a merger of JS Foundation and Node.js Foundation. OpenJS Promotes the JavaScript and web ecosystem by hosting projects and funds activities that benefit the ecosystem. The Open ...
. OpenJS Foundation is facilitated by the
Linux Foundation
The Linux Foundation (LF) is a non-profit technology consortium founded in 2000 as a merger between Open Source Development Labs and the Free Standards Group to standardize Linux, support its growth, and promote its commercial adoption. Additi ...
's Collaborative Projects program.
Corporate users of Node.js software include
GoDaddy
GoDaddy Inc. is an American publicly traded Internet domain registrar and web hosting company headquartered in Tempe, Arizona, and incorporated in Delaware.
, GoDaddy has more than 21 million customers and over 6,600 employees worldwide. The co ...
,
Groupon
Groupon is an American global e-commerce marketplace connecting subscribers with local merchants by offering activities, travel, goods and services in 13 countries. Based in Chicago, Groupon was launched there in November 2008, launching soon af ...
,
IBM,
LinkedIn
LinkedIn () is an American business and employment-oriented online service that operates via websites and mobile apps. Launched on May 5, 2003, the platform is primarily used for professional networking and career development, and allows job se ...
,
Microsoft
Microsoft Corporation is an American multinational technology corporation producing computer software, consumer electronics, personal computers, and related services headquartered at the Microsoft Redmond campus located in Redmond, Washing ...
,
Netflix
Netflix, Inc. is an American subscription video on-demand over-the-top streaming service and production company based in Los Gatos, California. Founded in 1997 by Reed Hastings and Marc Randolph in Scotts Valley, California, it offers a fil ...
,
PayPal
PayPal Holdings, Inc. is an American multinational financial technology company operating an online payments system in the majority of countries that support online money transfers, and serves as an electronic alternative to traditional paper ...
,
SAP
Sap is a fluid transported in xylem cells (vessel elements or tracheids) or phloem sieve tube elements of a plant. These cells transport water and nutrients throughout the plant.
Sap is distinct from latex, resin, or cell sap; it is a separa ...
,
Walmart
Walmart Inc. (; formerly Wal-Mart Stores, Inc.) is an American multinational retail corporation that operates a chain of hypermarkets (also called supercenters), discount department stores, and grocery stores from the United States, headquarter ...
,
Yahoo!
Yahoo! (, styled yahoo''!'' in its logo) is an American web services provider. It is headquartered in Sunnyvale, California and operated by the namesake company Yahoo Inc., which is 90% owned by investment funds managed by Apollo Global Man ...
, and
Amazon Web Services
Amazon Web Services, Inc. (AWS) is a subsidiary of Amazon.com, Amazon that provides Software as a service, on-demand cloud computing computing platform, platforms and Application programming interface, APIs to individuals, companies, and gover ...
.
History
![Ryan Dahl](https://upload.wikimedia.org/wikipedia/commons/b/b2/Ryan_Dahl.jpg)
Node.js was written initially by
Ryan Dahl
Ryan Dahl (born 1981) is an American software engineer who is best known for creating the Node.js JavaScript runtime as well as the Deno JavaScript/TypeScript runtime.
Biography
Dahl grew up in San Diego, California. His mother bought him an ...
in 2009,
about thirteen years after the introduction of the first server-side JavaScript environment,
Netscape's LiveWire Pro Web. The initial release supported only Linux and Mac OS X. Its development and maintenance was led by Dahl and later sponsored by
Joyent
Joyent Inc. was a software and services company based in San Francisco, California. Specializing in cloud computing, it marketed infrastructure-as-a-service.
On June 15, 2016, the company was acquired by Samsung Electronics.
Services
Triton, Joye ...
.
Dahl criticized the limited possibilities of the most popular web server in 2009,
Apache HTTP Server
The Apache HTTP Server ( ) is a free and open-source cross-platform web server software, released under the terms of Apache License 2.0. Apache is developed and maintained by an open community of developers under the auspices of the Apache So ...
, to handle a lot of concurrent connections (up to 10,000 and more) and the most common way of creating code (sequential programming), when code either blocked the entire process or implied multiple execution stacks in the case of simultaneous connections.
Dahl demonstrated the project at the inaugural European JSConf on November 8, 2009.
[Sams Teach Yourself Node.js in 24 Hours](_blank)
Sams Publishing, 05-Sep-2012 Node.js combined
Google
Google LLC () is an American multinational technology company focusing on search engine technology, online advertising, cloud computing, computer software, quantum computing, e-commerce, artificial intelligence, and consumer electronics. ...
's
V8 JavaScript engine, an
event loop In computer science, the event loop is a programming construct or design pattern that waits for and dispatches events or messages in a program. The event loop works by making a request to some internal or external "event provider" (that generally ...
, and a low-level
I/O API
An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software Interface (computing), interface, offering a service to other pieces of software. A document or standa ...
.
[Professional Node.js: Building JavaScript Based Scalable Software](_blank)
John Wiley & Sons, 01-Oct-2012
In January 2010, a
package manager
A package manager or package-management system is a collection of software tools that automates the process of installing, upgrading, configuring, and removing computer programs for a computer in a consistent manner.
A package manager deals wi ...
was introduced for the Node.js environment called
''npm''. The package manager makes it easier for programmers to publish and share source code of Node.js packages and is designed to simplify installation, updating, and uninstallation of packages.
In June 2011, Microsoft and Joyent implemented a native
Windows
Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
version of Node.js. The first Node.js build supporting Windows was released in July 2011.
In January 2012, Dahl stepped aside, promoting coworker and ''
npm'' creator Isaac Schlueter to manage the project. In January 2014, Schlueter announced that Timothy J. Fontaine would lead the project.
In December 2014, Fedor Indutny started io.js, a
fork
In cutlery or kitchenware, a fork (from la, furca 'pitchfork') is a utensil, now usually made of metal, whose long handle terminates in a head that branches into several narrow and often slightly curved tines with which one can spear foods ei ...
of Node.js. Due to the internal conflict over Joyent's governance, io.js was created as an
open governance alternative with a separate technical committee.
[Q&A: Why io.js decided to fork Node.js](_blank)
InfoWorld
''InfoWorld'' (abbreviated IW) is an information technology media business. Founded in 1978, it began as a monthly magazine. In 2007, it transitioned to a web-only publication. Its parent company today is International Data Group, and its siste ...
Tech Watch Unlike Node.js, the authors planned to keep io.js up-to-date with the latest releases of the Google V8 JavaScript engine.
In February 2015, the intent to form a neutral Node.js Foundation was announced. By June 2015, the Node.js and io.js communities voted to work together under the Node.js Foundation.
In September 2015, Node.js v0.12 and io.js v3.3 were merged back together into Node v4.0. This merge brought V8
ES6
ECMAScript (; ES) is a JavaScript standard intended to ensure the interoperability of web pages across different browsers. It is standardized by Ecma International in the documenECMA-262
ECMAScript is commonly used for client-side scripting o ...
features into Node.js and a long-term support release cycle. As of 2016, the io.js website recommends that developers switch back to Node.js and that no further releases of io.js are planned due to the merge.
In 2019, the JS Foundation and Node.js Foundation merged to form the
OpenJS Foundation
The OpenJS Foundation is an organization that was founded in 2019 from a merger of JS Foundation and Node.js Foundation. OpenJS Promotes the JavaScript and web ecosystem by hosting projects and funds activities that benefit the ecosystem. The Open ...
.
In September 2022, Node.js 18.9.0 was released.
Overview
Node.js allows the creation of
Web server
A web server is computer software and underlying hardware that accepts requests via HTTP (the network protocol created to distribute web content) or its secure variant HTTPS. A user agent, commonly a web browser or web crawler, initiate ...
s and networking tools using
JavaScript
JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
and a collection of "modules" that handle various core functionalities.
[Smashing Node.js: JavaScript Everywhere](_blank)
John Wiley & Sons, 14-Aug-2012 Modules are provided for
file system
In computing, file system or filesystem (often abbreviated to fs) is a method and data structure that the operating system uses to control how data is stored and retrieved. Without a file system, data placed in a storage medium would be one larg ...
I/O, networking (
DNS
The Domain Name System (DNS) is a hierarchical and distributed naming system for computers, services, and other resources in the Internet or other Internet Protocol (IP) networks. It associates various information with domain names assigned to ...
,
HTTP
The Hypertext Transfer Protocol (HTTP) is an application layer protocol in the Internet protocol suite model for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web, ...
,
TCP,
TLS/SSL, or
UDP),
binary
Binary may refer to:
Science and technology Mathematics
* Binary number, a representation of numbers using only two digits (0 and 1)
* Binary function, a function that takes two arguments
* Binary operation, a mathematical operation that t ...
data (buffers),
cryptography
Cryptography, or cryptology (from grc, , translit=kryptós "hidden, secret"; and ''graphein'', "to write", or ''-logia'', "study", respectively), is the practice and study of techniques for secure communication in the presence of adver ...
functions,
data streams, and other core functions.
Node.js's modules use an API designed to reduce the complexity of writing server applications.
[Node.js Essentials](_blank)
Packt Publishing, 10-Nov-2015
JavaScript is the only language that Node.js supports natively, but many
compile-to-JS languages are available. As a result, Node.js applications can be written in
CoffeeScript
CoffeeScript is a programming language that compiles to JavaScript. It adds syntactic sugar inspired by Ruby, Python, and Haskell in an effort to enhance JavaScript's brevity and readability. Specific additional features include list comprehensio ...
,
Dart
Dart or DART may refer to:
* Dart, the equipment in the game of darts
Arts, entertainment and media
* Dart (comics), an Image Comics superhero
* Dart, a character from ''G.I. Joe''
* Dart, a ''Thomas & Friends'' railway engine character
* Dar ...
,
TypeScript
TypeScript is a free and open source programming language
A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are ...
,
ClojureScript
Clojure (, like ''closure'') is a dynamic and functional dialect of the Lisp programming language on the Java platform. Like other Lisp dialects, Clojure treats code as data and has a Lisp macro system. The current development process is com ...
and others.
Node.js is primarily used to build network programs such as Web servers.
[Node.js for PHP Developers](_blank)
O'Reilly Media, Inc., 2013 The most significant difference between Node.js and
PHP
PHP is a general-purpose scripting language geared toward web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995. The PHP reference implementation is now produced by The PHP Group ...
is that most functions in PHP
block
Block or blocked may refer to:
Arts, entertainment and media Broadcasting
* Block programming, the result of a programming strategy in broadcasting
* W242BX, a radio station licensed to Greenville, South Carolina, United States known as ''96.3 ...
until completion (commands execute only after previous commands finish), while Node.js functions are
non-blocking (commands execute
concurrently or even in
parallel
Parallel is a geometric term of location which may refer to:
Computing
* Parallel algorithm
* Parallel computing
* Parallel metaheuristic
* Parallel (software), a UNIX utility for running programs in parallel
* Parallel Sysplex, a cluster of IBM ...
,
and use
callbacks to signal completion or failure).
Node.js is officially supported on
Linux
Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which ...
, and
Microsoft Windows
Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
8.1 and Server 2012 (and later),
with tier 2 support for
SmartOS
SmartOS is a free and open-source SVR4 hypervisor based on the UNIX operating system that combines OpenSolaris technology with Linux's KVM virtualization. Its core kernel contributed to the illumos project. It features several technologies: C ...
and
IBM AIX
AIX (Advanced Interactive eXecutive, pronounced , "ay-eye-ex") is a series of Proprietary software, proprietary Unix operating systems developed and sold by IBM for several of its computer platforms.
Background
Originally released for the ...
and experimental support for
FreeBSD
FreeBSD is a free and open-source Unix-like operating system descended from the Berkeley Software Distribution (BSD), which was based on Research Unix. The first version of FreeBSD was released in 1993. In 2005, FreeBSD was the most popular ...
.
OpenBSD
OpenBSD is a security-focused, free and open-source, Unix-like operating system based on the Berkeley Software Distribution (BSD). Theo de Raadt created OpenBSD in 1995 by forking NetBSD 1.0. According to the website, the OpenBSD project em ...
also works, and LTS versions available for
IBM i
IBM i (the ''i'' standing for ''integrated'') is an operating system developed by IBM for IBM Power Systems. It was originally released in 1988 as OS/400, as the sole operating system of the IBM AS/400 line of systems. It was renamed to i5/OS in ...
(AS/400). The provided source code may also be built on similar operating systems to those officially supported or be modified by third parties to support others such as
NonStop OS
NonStop is a series of server computers introduced to market in 1976 by Tandem Computers Inc., beginning with the NonStop product line, which was followed by the Hewlett-Packard Integrity NonStop product line extension. It is currently offered by ...
and
Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and ot ...
servers.
Platform architecture
Node.js brings
event-driven programming
In computer programming, event-driven programming is a programming paradigm in which the flow of the program is determined by events such as user actions ( mouse clicks, key presses), sensor outputs, or message passing from other programs or t ...
to
web server
A web server is computer software and underlying hardware that accepts requests via HTTP (the network protocol created to distribute web content) or its secure variant HTTPS. A user agent, commonly a web browser or web crawler, initiate ...
s, enabling development of fast web servers in JavaScript.
Developers can create scalable servers without using
threading, by using a simplified model of
event-driven programming
In computer programming, event-driven programming is a programming paradigm in which the flow of the program is determined by events such as user actions ( mouse clicks, key presses), sensor outputs, or message passing from other programs or t ...
that uses callbacks to signal the completion of a task.
Node.js connects the ease of a scripting language (JavaScript) with the power of Unix network programming.
Node.js was built on top of
Google
Google LLC () is an American multinational technology company focusing on search engine technology, online advertising, cloud computing, computer software, quantum computing, e-commerce, artificial intelligence, and consumer electronics. ...
's
V8 JavaScript engine
V8 is a free and open-source JavaScript engine developed by the Chromium Project for Google Chrome and Chromium web browsers. The project’s creator is Lars Bak. The first version of the V8 engine was released at the same time as the first v ...
since it was open-sourced under the
BSD license
BSD licenses are a family of permissive free software licenses, imposing minimal restrictions on the use and distribution of covered software. This is in contrast to copyleft licenses, which have share-alike requirements. The original BSD lic ...
. It is proficient with internet fundamentals such as
HTTP
The Hypertext Transfer Protocol (HTTP) is an application layer protocol in the Internet protocol suite model for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web, ...
,
DNS
The Domain Name System (DNS) is a hierarchical and distributed naming system for computers, services, and other resources in the Internet or other Internet Protocol (IP) networks. It associates various information with domain names assigned to ...
, and
TCP.
JavaScript
JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
was also a well-known language, making Node.js accessible to the
web development community.
Industry support
There are thousands of open-source libraries for Node.js, most of them hosted on the
npm website. There are multiple developer conferences and events that support the Node.js community, including NodeConf, Node Interactive, and Node Summit as well as a number of regional events.
The open-source community has developed
web framework
A web framework (WF) or web application framework (WAF) is a software framework that is designed to support the development of web applications including web services, web resources, and web APIs. Web frameworks provide a standard way to build and ...
s to accelerate the development of applications. Such frameworks include Connect,
Express.js,
Socket.IO
Socket.IO is an event-driven library for real-time web applications. It enables real-time, bi-directional communication between web clients and servers. It consists of two parts: a client-side library that runs in the browser, and a server-s ...
, Feathers.js, Koa.js, Hapi.js,
Sails.js
Sails.js (or Sails) is a model–view–controller (MVC) web application framework developed atop the Node.js environment, released as free and open-source software under the MIT License. It is designed to make it easy to build custom, enterpris ...
,
Meteor
A meteoroid () is a small rocky or metallic body in outer space.
Meteoroids are defined as objects significantly smaller than asteroids, ranging in size from grains to objects up to a meter wide. Objects smaller than this are classified as micr ...
, Derby, and many others.
[Express.js Guide: The Comprehensive Book on Express.js](_blank)
Azat Mardan, 28-May-2014 Various packages have also been created for interfacing with other languages or runtime environments such as
Microsoft .NET
The Microsoft .NET strategy is a marketing plan that Microsoft followed in the early 2000s. Steve Ballmer described it as the company's "most ambitious undertaking since Internet Strategy Day in 1995". In support of this strategy, between 2000 and ...
.
Modern desktop
IDEs Ides or IDES may refer to:
Calendar dates
* Ides (calendar), a day in the Roman calendar that fell roughly in the middle of the month. In March, May, July, and October it was the 15th day of the month; in other months it was the 13th.
**Ides of Mar ...
provide editing and debugging features specifically for Node.js applications. Such IDEs include
Atom
Every atom is composed of a nucleus and one or more electrons bound to the nucleus. The nucleus is made of one or more protons and a number of neutrons. Only the most common variety of hydrogen has no neutrons.
Every solid, liquid, gas, and ...
,
Brackets
A bracket is either of two tall fore- or back-facing punctuation marks commonly used to isolate a segment of text or data from its surroundings. Typically deployed in symmetric pairs, an individual bracket may be identified as a 'left' or 'r ...
,
JetBrains
JetBrains s.r.o. (formerly IntelliJ Software s.r.o.) is a Czech software development company which makes tools for software developers and project managers. , the company has offices in Prague; Munich; Berlin; Boston, Massachusetts; Amsterda ...
WebStorm
JetBrains s.r.o. (formerly IntelliJ Software s.r.o.) is a Czech software development company which makes tools for software developers and project managers. , the company has offices in Prague; Munich; Berlin; Boston, Massachusetts; Amsterdam; ...
,
Microsoft Visual Studio
Visual Studio is an integrated development environment (IDE) from Microsoft. It is used to develop computer programs including websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development platforms such a ...
(with Node.js Tools for Visual Studio, or
TypeScript
TypeScript is a free and open source programming language
A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are ...
with Node definitions,)
NetBeans
NetBeans is an integrated development environment (IDE) for Java (programming language), Java. NetBeans allows applications to be developed from a set of modular software components called ''modules''. NetBeans runs on Microsoft Windows, Windows, ...
,
Nodeclipse
Nodeclipse is a set of third-party developer solutions for Eclipse for programming in JavaScript, CoffeeScript with focus on Node.js.
Nodeclipse also refers to the team that makes this software as free open-source on GitHub.
Nodeclipse Eclips ...
Enide Studio (
Eclipse
An eclipse is an astronomical event that occurs when an astronomical object or spacecraft is temporarily obscured, by passing into the shadow of another body or by having another body pass between it and the viewer. This alignment of three ce ...
-based), and
Visual Studio Code
Visual Studio Code, also commonly referred to as VS Code, is a source-code editor made by Microsoft with the Electron Framework, for Windows, Linux and macOS. Features include support for debugging, syntax highlighting, intelligent code complet ...
.
Certain online web-based IDEs also support Node.js, such as
Codeanywhere Codeanywhere is a cross-platform cloud integrated development environment (IDE) created by Codeanywhere, Inc. Codeanywhere enables users to write, edit, collaborate, and run web development projects from a web browser or mobile device.
Codeanywher ...
,
Codenvy
Eclipse Che is an open-source, Java-based developer workspace server and Online IDE (integrated development environment). It includes a multi-user remote development platform. The workspace server comes with a flexible RESTful webservice. It a ...
,
Cloud9 IDE
Cloud9 IDE is an Online IDE (integrated development environment), published as open source from version 2.0, until version 3.0. It supports multiple programming languages, including C, C++, PHP, Ruby, Perl, Python, JavaScript with Node.js, an ...
, Koding, and the visual flow editor in
Node-RED
Node-RED is a flow-based programming, flow-based development tool for visual programming language, visual programming developed originally by IBM for wiring together hardware devices, Application programming interface, APIs and online services as ...
.
Node.js is supported across a number of cloud-hosting platforms like
Jelastic
Jelastic is a cloud platform software vendor that provides multi-cloud Platform as a Service-based on container technology for hosting service providers, ISVs, telecommunication companies, enterprises and developers. The platform is available as ...
,
Google Cloud Platform
Google Cloud Platform (GCP), offered by Google, is a suite of cloud computing services that runs on the same infrastructure that Google uses internally for its end-user products, such as Google Search, Gmail, Google Drive, and YouTube. Alongside ...
,
AWS Elastic Beanstalk
AWS Elastic Beanstalk is an Orchestration (computing), orchestration service offered by Amazon Web Services for deploying applications which orchestrates various AWS services, including Amazon EC2, EC2, Amazon S3, S3, Amazon Simple Notification S ...
,
Joyent
Joyent Inc. was a software and services company based in San Francisco, California. Specializing in cloud computing, it marketed infrastructure-as-a-service.
On June 15, 2016, the company was acquired by Samsung Electronics.
Services
Triton, Joye ...
and others.
Releases
New major releases of Node.js are cut from the
GitHub
GitHub, Inc. () is an Internet hosting service for software development and version control using Git. It provides the distributed version control of Git plus access control, bug tracking, software feature requests, task management, continuous ...
main branch every six months. Even-numbered versions are cut in April and odd-numbered versions are cut in October. When a new odd version is released, the previous even version undergoes transition to
Long Term Support
Long-term support (LTS) is a product lifecycle management policy in which a stable release of computer software is maintained for a longer period of time than the standard edition. The term is typically reserved for open-source software, where i ...
(LTS), which gives that version 18 months of active support from the date it is designated LTS. After these 18 months expire, an LTS release receives an additional 12 months of maintenance support. An active version receives non-breaking backports of changes a few weeks after they land in the current release. A maintenance release receives only critical fixes and documentation updates.
The LTS Working Group manages strategy and policy in collaboration with the Technical Steering Committee of the Node.js Foundation.
Technical details
Node.js is a JavaScript runtime environment that processes incoming requests in a loop, called the
event loop In computer science, the event loop is a programming construct or design pattern that waits for and dispatches events or messages in a program. The event loop works by making a request to some internal or external "event provider" (that generally ...
.
Internals
Node.js uses
libuv
libuv is a multi-platform C library that provides support for asynchronous I/O based on event loops. It supports epoll(4), kqueue(2), Windows IOCP, and Solaris event ports. It is primarily designed for use in Node.js but it is also used by ...
under the hood to handle asynchronous events. Libuv is an abstraction layer for network and file system functionality on both Windows and
POSIX
The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming interf ...
-based systems such as Linux,
macOS
macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac computers. Within the market of desktop and lapt ...
, OSS on
NonStop, and Unix.
Threading
Node.js operates on a
single-thread event loop In computer science, the event loop is a programming construct or design pattern that waits for and dispatches events or messages in a program. The event loop works by making a request to some internal or external "event provider" (that generally ...
, using
non-blocking I/O
In computer science, asynchronous I/O (also non-sequential I/O) is a form of input/output processing that permits other processing to continue before the transmission has finished. A name used for asynchronous I/O in the Windows API is overlappe ...
calls, allowing it to support tens of thousands of concurrent connections without incurring the cost of thread
context switch
In computing, a context switch is the process of storing the state of a process or thread, so that it can be restored and resume execution at a later point, and then restoring a different, previously saved, state. This allows multiple processes ...
ing. The design of sharing a single thread among all the requests that use the
observer pattern
In software design and engineering, the observer pattern is a software design pattern in which an object, named the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by ca ...
is intended for building highly concurrent applications, where any function performing I/O must use a
callback
Callback may refer to:
* Callback (comedy), a joke which refers to one previously told
* Callback (computer programming), executable code that is passed as a parameter to other code
* Callback (telecommunications), the telecommunications event tha ...
. To accommodate the single-threaded event loop, Node.js uses the
libuv
libuv is a multi-platform C library that provides support for asynchronous I/O based on event loops. It supports epoll(4), kqueue(2), Windows IOCP, and Solaris event ports. It is primarily designed for use in Node.js but it is also used by ...
library—which, in turn, uses a fixed-sized thread pool that handles some of the non-blocking asynchronous I/O operations.
A thread pool handles the execution of parallel tasks in Node.js. The main thread function call posts tasks to the shared task queue, which threads in the thread pool pull and execute. Inherently non-blocking system functions such as networking translate to kernel-side non-blocking sockets, while inherently blocking system functions such as file I/O run in a blocking way on their own threads. When a thread in the thread pool completes a task, it informs the main thread of this, which in turn, wakes up and executes the registered callback.
A downside of this single-threaded approach is that Node.js does not allow
vertical scaling by increasing the number of
CPU core
A central processing unit (CPU), also called a central processor, main processor or just processor, is the electronic circuitry that executes instructions comprising a computer program. The CPU performs basic arithmetic, logic, controlling, and ...
s of the machine it is running on without using an additional module, such as cluster,
StrongLoop Process Manager, or pm2. However, developers can increase the default number of threads in the libuv thread pool. The server
operating system (OS) is likely to distribute these threads across multiple cores. Another problem is that long-lasting computations and other CPU-bound tasks freeze the entire event-loop until completion.
V8
V8 is the JavaScript execution engine which was initially built for
Google Chrome
Google Chrome is a cross-platform web browser developed by Google. It was first released in 2008 for Microsoft Windows, built with free software components from Apple WebKit and Mozilla Firefox. Versions were later released for Linux, macOS ...
. It was then open-sourced by Google in 2008. Written in
C++
C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
, V8 compiles JavaScript source code to native machine code
at runtime.
As of 2016, it also includes Ignition, a
bytecode interpreter
Bytecode (also called portable code or p-code) is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (normall ...
.
Package management
npm is the pre-installed package manager for the Node.js server platform. It installs Node.js programs from th
npm registry organizing the installation and management of third-party Node.js programs. Packages in the npm registry can range from simple helper libraries such as
Lodash
Lodash is a JavaScript library which provides utility functions for common programming tasks using the functional programming paradigm.
History
''See also Underscore § History.''
Lodash is a fork of Underscore.js.
It joined the Dojo Fou ...
to task runners such as
Grunt.
Unified API
Node.js can be combined with a browser with your site , a database that supports JSON data (such as
Postgres
PostgreSQL (, ), also known as Postgres, is a free and open-source relational database management system (RDBMS) emphasizing extensibility and SQL compliance. It was originally named POSTGRES, referring to its origins as a successor to the In ...
,
MongoDB
MongoDB is a source-available cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas. MongoDB is developed by MongoDB Inc. and licensed under the Serve ...
, or
CouchDB
Apache CouchDB is an open-source document-oriented NoSQL database, implemented in Erlang.
CouchDB uses multiple formats and protocols to store, transfer, and process its data. It uses JSON to store data, JavaScript as its query language using M ...
) and
JSON
JSON (JavaScript Object Notation, pronounced ; also ) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other ser ...
for a unified JavaScript development stack. With the adaptation of what were essentially server-side development patterns such as
MVC
MVC may refer to:
Science and technology
* Maximum-value composite procedure, an imaging procedure
* Multivariable calculus, a concept in mathematics
* Multivariable control, a concept in process engineering
* Mechanical vapor compression, a desal ...
,
MVP
In team sports, a most valuable player award, abbreviated 'MVP award', is an honor typically bestowed upon an individual (or individuals, in the instance of a tie) whose individual performance is the greatest in an entire league, for a particu ...
,
MVVM, etc., Node.js allows the
reuse
Reuse is the action or practice of using an item, whether for its original purpose (conventional reuse) or to fulfill a different function ( creative reuse or repurposing). It should be distinguished from recycling, which is the breaking down of u ...
of the same model and service interface between client side and server side.
Event loop
Node.js registers with the operating system so the OS notifies it of connections and issues a callback. Within the Node.js runtime, each connection is a small
heap allocation
In computer science, manual memory management refers to the usage of manual instructions by the programmer to identify and deallocate unused objects, or garbage. Up until the mid-1990s, the majority of programming languages used in industry suppo ...
. Traditionally, relatively heavyweight OS processes or threads handled each connection. Node.js uses an event loop for scalability, instead of processes or threads. In contrast to other event-driven servers, Node.js's event loop does not need to be called explicitly. Instead, callbacks are defined, and the server automatically enters the event loop at the end of the callback definition. Node.js exits the event loop when there are no further callbacks to be performed.
WebAssembly
Node.js supports
WebAssembly
WebAssembly (sometimes abbreviated Wasm) defines a portable binary-code format and a corresponding text format for executable programs as well as software interfaces for facilitating interactions between such programs and their host environment ...
and as of Node 14 has experimental support of
WASI, the WebAssembly System Interface.
Native bindings
Node.js provides a way to create "add-ons" via a
C-based API called N-API, which can be used to produce loadable (importable)
.node
modules from source code written in C/C++.
The modules can be directly loaded into memory and executed from within JS environment as simple CommonJS modules. The implementation of the N-API relies on internal C/C++ Node.js and V8 objects requiring users
to import (
#include) Node.js specific
headers into their native source code.
As the Node.js platform constantly evolves, the API compatibility is subject to changes, and may sometimes get broken by a new version (as a consequence, modules have to be built against specific Node.js versions to work correctly). To address the issue, third parties have introduced open-sourced С/С++ wrappers on top of the API that partially alleviate the problem. They simplify interfaces, but as a side effect they may also introduce complexity which maintainers have to deal with. Even though the core functionality of Node.js resides in a JavaScript built-in library, modules written in C++ can be used to enhance capabilities and to improve performance of applications.
In order to produce such modules one needs to have an appropriate C++ compiler and necessary headers (the latter are typically shipped with Node.js itself):
gcc,
clang
Clang is a compiler front end for the C, C++, Objective-C, and Objective-C++ programming languages, as well as the OpenMP, OpenCL, RenderScript, CUDA, and HIP frameworks. It acts as a drop-in replacement for the GNU Compiler Collection (GCC), ...
or
MSVC++.
The N-API is similar to
Java Native Interface
In software design, the Java Native Interface (JNI) is a foreign function interface programming framework that enables Java code running in a Java virtual machine (JVM) to call and be called by
native applications (programs specific to a hardwa ...
.
Project governance
In 2015, various branches of the greater Node.js community began working under the vendor-neutral Node.js Foundation. The stated purpose of the organization "is to enable widespread adoption and help accelerate development of Node.js and other related modules through an open governance model that encourages participation, technical contribution, and a framework for long-term stewardship by an ecosystem invested in Node.js' success."
The Node.js Foundation Technical Steering Committee (TSC) is the technical governing body of the Node.js Foundation. The TSC is responsible for the core Node.js repo as well as dependent and adjacent projects. Generally the TSC delegates the administration of these projects to working groups or committees. The LTS group that manages long term supported releases is one such group. Other current groups include Website, Streams, Build, Diagnostics, i18n, Evangelism, Docker, Addon API, Benchmarking, Post-mortem, Intl, Documentation, and Testing.
In August 2017, a third of the TSC members resigned due to a dispute related to the project's code of conduct.
[Whittaker, Zack, ]
After governance breakdown, Node.js leaders fight for its survival
', ZDNet, 25 August 2017
See also
*
Deno—a back-end runtime environment for JavaScript and TypeScript, also created by Ryan Dahl.
References
Further reading
*
*
*
*
*
External links
*
*
{{Use dmy dates, date=November 2019
2009 software
Free software programmed in C++
Free software programmed in JavaScript
JavaScript libraries
Joyent
Linux Foundation projects
Software using the MIT license