1# Maintaining Dependencies 2 3Node.js depends on additional components beyond the Node.js code 4itself. These dependencies provide both native and JavaScript code 5and are built together with the code under the `src` and `lib` 6directories to create the Node.js binaries. 7 8All dependencies are located within the `deps` directory. 9This a list of all the dependencies: 10 11* [acorn][] 12* [ada][] 13* [base64][] 14* [brotli][] 15* [c-ares 1.20.1][] 16* [cjs-module-lexer][] 17* [corepack][] 18* [googletest 2dd1c13][] 19* [histogram][] 20* [icu-small][] 21* [llhttp][] 22* [minimatch][] 23* [nghttp2][] 24* [ngtcp2][] 25* [npm][] 26* [openssl][] 27* [postject][] 28* [simdutf 4.0.4][] 29* [undici 5.26.4][] 30* [uv][] 31* [uvwasi 0.0.19][] 32* [V8][] 33* [zlib][] 34 35Any code which meets one or more of these conditions should 36be managed as a dependency: 37 38* originates in an upstream project and is maintained 39 in that upstream project. 40* is not built from the `preferred form of the work for 41 making modifications to it` (see 42 [GNU GPL v2, section 3.](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) 43 when `make node` is run. A good example is 44 WASM code generated from C (the preferred form). 45 Typically generation is only supported on a subset of platforms, needs 46 additional tools, and is pre-built outside of the `make node` 47 step and then committed as a WASM binary in the directory 48 for the dependency under the `deps` directory. 49 50By default all dependencies are bundled into the Node.js 51binary, however, `configure` options should be available to 52use an externalized version at runtime when: 53 54* the dependency provides native code and is available as 55 a shared library in one or more of the common Node.js 56 distributions. 57* the dependency provides JavaScript and is not built 58 from the `preferred form of the work for making modifications 59 to it` when `make node` is run. 60 61Many distributions use externalized dependencies for one or 62more of these reasons: 63 641. They have a requirement to build everything that they ship 65 from the `preferred form of the work for making 66 modifications to it`. This means that they need to 67 replace any pre-built components (for example WASM 68 binaries) with an equivalent that they have built. 692. They manage the dependency separately as it is used by 70 more applications than just Node.js. Linking against 71 a shared library allows them to manage updates and 72 CVE fixes against the library instead of having to 73 patch all of the individual applications. 743. They have a system wide configuration for the 75 dependency that all applications should respect. 76 77## Supporting externalized dependencies with native code 78 79Support for externalized dependencies with native code for which a 80shared library is available can added by: 81 82* adding options to `configure.py`. These are added to the 83 shared\_optgroup and include an options to: 84 * enable use of a shared library 85 * set the name of the shared library 86 * set the path to the directory with the includes for the 87 shared library 88 * set the path to where to find the shared library at 89 runtime 90* add a call to configure\_library() to `configure.py` for the 91 library at the end of list of existing configure\_library() calls. 92 If there are additional libraries that are required it is 93 possible to list more than one with the `pkgname` option. 94* in `node.gypi` guard the build for the dependency 95 with `node_shared_depname` so that it is only built if 96 the dependency is being bundled into Node.js itself. For example: 97 98```text 99 [ 'node_shared_brotli=="false"', { 100 'dependencies': [ 'deps/brotli/brotli.gyp:brotli' ], 101 }], 102``` 103 104## Supporting externalizable dependencies with JavaScript code 105 106Support for an externalizable dependency with JavaScript code 107can be added by: 108 109* adding an entry to the `sharable_builtins` map in 110 `configure.py`. The path should correspond to the file 111 within the deps directory that is normally bundled into 112 Node.js. For example `deps/cjs-module-lexer/lexer.js`. 113 This will add a new option for building with that dependency 114 externalized. After adding the entry you can see 115 the new option by running `./configure --help`. 116 117* adding a call to `AddExternalizedBuiltin` to the constructor 118 for BuiltinLoader in `src/node_builtins.cc` for the 119 dependency using the `NODE_SHARED_BUILTLIN` #define generated for 120 the dependency. After running `./configure` with the new 121 option you can find the #define in `config.gypi`. You can cut and 122 paste one of the existing entries and then update to match the 123 import name for the dependency and the #define generated. 124 125## Supporting non-externalized dependencies with JavaScript code 126 127If the dependency consists of JavaScript in the 128`preferred form of the work for making modifications to it`, it 129can be added as a non-externalizable dependency. In this case 130simply add the path to the JavaScript file in the `deps_files` 131list in the `node.gyp` file. 132 133## Updating dependencies 134 135Most dependencies are automatically updated by 136[dependency-update-action][] that runs weekly. 137However, it is possible to manually update a dependency by running 138the corresponding script in `tools/update-deps`. 139[OpenSSL][] has its own update action: [update-openssl-action][]. 140[npm-cli-bot](https://github.com/npm/cli/blob/latest/.github/workflows/create-node-pr.yml) 141takes care of [npm][] update, it is maintained by the npm team. 142 143## Dependency list 144 145### acorn 146 147The [acorn](https://github.com/acornjs/acorn) dependency is a JavaScript parser. 148[acorn-walk](https://github.com/acornjs/acorn/tree/master/acorn-walk) is 149an abstract syntax tree walker for the ESTree format. 150 151### ada 152 153The [ada](https://github.com/ada-url/ada) dependency is a 154fast and spec-compliant URL parser written in C++. 155 156### base64 157 158The [base64](https://github.com/aklomp/base64) dependency is a base64 159stream encoding/decoding library in C99 with SIMD and OpenMP acceleration. 160It also contains wrapper functions to encode/decode simple 161length-delimited strings. 162 163### brotli 164 165The [brotli](https://github.com/google/brotli) dependency is 166used for the homonym generic-purpose lossless compression algorithm. 167 168### c-ares 1.20.1 169 170The [c-ares](https://github.com/c-ares/c-ares) is a C library 171for asynchronous DNS requests. 172 173### cjs-module-lexer 174 175The [cjs-module-lexer](https://github.com/nodejs/node/tree/HEAD/deps/cjs-module-lexer) 176dependency is used within the Node.js ESM implementation to detect the 177named exports of a CommonJS module. 178See [maintaining-cjs-module-lexer][] for more information. 179 180## corepack 181 182The [corepack](https://github.com/nodejs/corepack) dependency is a 183zero-runtime-dependency Node.js script that acts as a bridge between 184Node.js projects and the package managers they are intended to 185be used with during development. 186In practical terms, Corepack will let you use Yarn and pnpm without having to 187install them - just like what currently happens with npm, which is shipped 188by Node.js by default. 189 190### googletest 2dd1c13 191 192The [googletest](https://github.com/google/googletest) dependency is Google’s 193C++ testing and mocking framework. 194 195### histogram 196 197The [histogram](https://github.com/HdrHistogram/HdrHistogram_c) dependency is 198a C port of High Dynamic Range (HDR) Histogram. 199 200### icu-small 201 202The [icu](http://site.icu-project.org) is widely used set of C/C++ 203and Java libraries providing Unicode and Globalization 204support for software applications. 205See [maintaining-icu][] for more informations. 206 207### llhttp 208 209The [llhttp](https://github.com/nodejs/llhttp) dependency is 210the http parser used by Node.js. 211See [maintaining-http][] for more informations. 212 213### minimatch 214 215The [minimatch](https://github.com/isaacs/minimatch) dependency is a 216minimal matching utility. 217 218### nghttp2 219 220The [nghttp2](https://github.com/nghttp2/nghttp2) dependency is a C library 221implementing HTTP/2 protocol. 222See [maintaining-http][] for more informations. 223 224### ngtcp2 225 226The ngtcp2 and nghttp3 dependencies provide the core functionality for 227QUIC and HTTP/3. 228 229The sources are pulled from: 230 231* ngtcp2: <https://github.com/ngtcp2/ngtcp2> 232* nghttp3: <https://github.com/ngtcp2/nghttp3> 233 234In both the `ngtcp2` and `nghttp3` git repos, the active development occurs 235in the default branch (currently named `main` in each). Tagged versions do not 236always point to the default branch. 237 238We only use a subset of the sources for each. 239 240The `nghttp3` library depends on `ngtcp2`. Both should always be updated 241together. From `ngtcp2` we only want the contents of the `lib` and `crypto` 242directories; from `nghttp3` we only want the contents of the `lib` directory. 243 244### npm 245 246The [npm](https://github.com/npm/cli) dependency is 247the package manager for JavaScript. 248 249New pull requests should be opened when a "next" version of npm has 250been released. Once the "next" version has been promoted to "latest" 251the PR should be updated as necessary. 252 253The specific Node.js release streams the new version will be able to land into 254are at the discretion of the release and LTS teams. 255 256This process only covers full updates to new versions of npm. Cherry-picked 257changes can be reviewed and landed via the normal consensus seeking process. 258 259### openssl 260 261The [openssl](https://github.com/quictls/openssl) dependency is a 262fork of OpenSSL to enable QUIC. 263[OpenSSL](https://www.openssl.org/) is toolkit for general-purpose 264cryptography and secure communication. 265 266Node.js currently uses the quictls/openssl fork, which closely tracks 267the main openssl/openssl releases with the addition of APIs to support 268the QUIC protocol. 269See [maintaining-openssl][] for more informations. 270 271### postject 272 273The [postject](https://github.com/nodejs/postject) dependency is used for the 274[Single Executable strategic initiative](https://github.com/nodejs/single-executable). 275 276### simdutf 4.0.4 277 278The [simdutf](https://github.com/simdutf/simdutf) dependency is 279a C++ library for fast UTF-8 decoding and encoding. 280 281### undici 5.26.4 282 283The [undici](https://github.com/nodejs/undici) dependency is an HTTP/1.1 client, 284written from scratch for Node.js.. 285See [maintaining-http][] for more informations. 286 287### uv 288 289The [libuv](https://github.com/libuv/libuv) dependency is a 290multi-platform support library with a focus on asynchronous I/O. 291It was primarily developed for use by Node.js. 292 293### uvwasi 0.0.19 294 295The [uvwasi](https://github.com/nodejs/uvwasi) dependency implements 296the WASI system call API, so that WebAssembly runtimes can easily 297implement WASI calls. 298Under the hood, uvwasi leverages libuv where possible for maximum portability. 299See [maintaining-web-assembly][] for more informations. 300 301### V8 302 303[V8](https://chromium.googlesource.com/v8/v8.git/) is Google's open source 304high-performance JavaScript and WebAssembly engine, written in C++. 305See [maintaining-V8][] for more informations. 306 307### zlib 308 309The [zlib](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/zlib) 310dependency lossless data-compression library, 311it comes from the Chromium team's zlib fork which incorporated 312performance improvements not currently available in standard zlib. 313 314[acorn]: #acorn 315[ada]: #ada 316[base64]: #base64 317[brotli]: #brotli 318[c-ares 1.20.1]: #c-ares-1200 319[cjs-module-lexer]: #cjs-module-lexer 320[corepack]: #corepack 321[dependency-update-action]: ../../../.github/workflows/tools.yml 322[googletest 2dd1c13]: #googletest-2dd1c13 323[histogram]: #histogram 324[icu-small]: #icu-small 325[llhttp]: #llhttp 326[maintaining-V8]: ./maintaining-V8.md 327[maintaining-cjs-module-lexer]: ./maintaining-cjs-module-lexer.md 328[maintaining-http]: ./maintaining-http.md 329[maintaining-icu]: ./maintaining-icu.md 330[maintaining-openssl]: ./maintaining-openssl.md 331[maintaining-web-assembly]: ./maintaining-web-assembly.md 332[minimatch]: #minimatch 333[nghttp2]: #nghttp2 334[ngtcp2]: #ngtcp2 335[npm]: #npm 336[openssl]: #openssl 337[postject]: #postject 338[simdutf 4.0.4]: #simdutf-404 339[undici 5.26.4]: #undici-5264 340[update-openssl-action]: ../../../.github/workflows/update-openssl.yml 341[uv]: #uv 342[uvwasi 0.0.19]: #uvwasi-0019 343[v8]: #v8 344[zlib]: #zlib 345