Registry / http-networking / node-http2

node-http2

JSON →
library4.0.1jsnpmunverified

The `node-http2` package (version 4.0.1) provides a pure JavaScript implementation of the HTTP/2 client and server protocols, aiming for API compatibility with Node.js's standard HTTPS module. Originally forked from `molnarg/node-http2`, this specific `kaazing/node-http2` version was released around 2017. Its primary differentiating features were its full JavaScript implementation and inclusion of server push capabilities prior to widespread native HTTP/2 support in Node.js. However, since Node.js v8.0.0 (released May 2017) included experimental built-in HTTP/2 support, and especially with its stabilization in Node.js v10.0.0, this package has been superseded. As such, it is no longer actively maintained and should generally not be used in new projects.

npm install node-http2
INSTALL
IMPORT
SIG · NODE-HTTP2
N
node-http2
http-networkingjavascriptv4.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createServer
import { createServer } from 'node-http2';
const http2 = require('http2'); // This often resolves to the native module
This package is CommonJS-first; for ES modules, bundlers might be required. Always explicitly refer to 'node-http2' to avoid conflicts with Node.js's built-in 'http2' module.
get
const http2 = require('node-http2'); http2.get(url, callback);
import { get } from 'node:http2'; // This is the native module API, not this package
The client-side `get` method is part of the package's API. Be careful not to confuse it with the native `node:http2` module which has a different, non-`get` centric client API.
Http2Server
const { Http2Server } = require('node-http2');
import { Http2Server } from 'http2'; // Will likely fail or resolve to native
While not directly exposed as `Http2Server` in the top-level API, internally this package defines server types. Direct import might not be typical for users, but it's important to differentiate from the native `http2.Http2Server`.

Starts an HTTPS/2 server on port 8080 using `node-http2`, serving a 'Hello world' response. Requires self-signed certificates for local testing.

const fs = require('fs'); const http2 = require('node-http2'); // Explicitly import this package // Ensure you have localhost.key and localhost.crt in an 'example' directory // For testing, you can generate self-signed certificates: // openssl genrsa -out example/localhost.key 2048 // openssl req -new -x509 -key example/localhost.key -out example/localhost.crt -days 365 -subj "/CN=localhost" const options = { key: fs.readFileSync('./example/localhost.key'), cert: fs.readFileSync('./example/localhost.crt') }; http2.createServer(options, function(request, response) { response.end('Hello world from node-http2!'); }).listen(8080, () => { console.log('node-http2 server listening on port 8080 (HTTPS/2)'); console.log('Try: curl --http2 -k https://localhost:8080/'); });
Debug
Known issues
breakingThis package (`node-http2` by Kaazing) is completely superseded by the native `http2` module included in Node.js core since v8.0.0 (stable in v10.0.0). Using this package in modern Node.js environments will cause dependency conflicts, unexpected behavior, and prevent access to newer HTTP/2 features and performance optimizations. Do not use this package for new development.
fix
Migrate to the built-in `node:http2` module. The API is similar but has differences, especially in stream handling. Consult the official Node.js documentation for `node:http2`.
affects: >=4.0.0
gotchaThe package is no longer maintained. This means it will not receive updates for security vulnerabilities, bug fixes, or compatibility with newer Node.js versions or HTTP/2 specification updates.
fix
Avoid using this package in production. If forced to use legacy code, thoroughly audit for known vulnerabilities and consider isolated execution environments.
affects: >=4.0.1
gotchaALPN (Application-Layer Protocol Negotiation) support within this `node-http2` package is explicitly stated to only work for Node.js versions >= 5.0. Earlier Node.js versions may encounter issues establishing HTTP/2 connections.
fix
Ensure your Node.js version is 5.0 or higher if using this package, though migrating to the native `node:http2` module is the vastly superior solution.
affects: >=4.0.0
deprecatedThe original `molnarg/node-http2` repository (from which this package was forked) explicitly marked itself as deprecated, advising users to switch to the Node.js built-in `http2` module. This deprecation applies to all forks, including this `kaazing/node-http2` package.
fix
Remove `node-http2` from your project dependencies and refactor your code to use `require('node:http2')` or `import * as http2 from 'node:http2';`.
affects: >=4.0.0
Errors
Common errors & fixes
Error: Cannot find module 'http2'
Attempting to `require('http2')` when the current Node.js version does not have the native HTTP/2 module enabled, or an incorrect path is used. Alternatively, if `node-http2` was intended, it might not be installed or resolved correctly.
fix
If intending to use Node.js's native module, ensure your Node.js version is >= 8.0.0 (for experimental) or >= 10.0.0 (for stable) and use `require('node:http2')`. If specifically targeting *this* `node-http2` package, ensure `npm install node-http2` has been run and use `require('node-http2')`.
TypeError: http2.createServer is not a function
This error often occurs when `require('http2')` resolves to the native Node.js `http2` module, which exposes `createSecureServer` and `createServer` directly but with potentially different arguments or behavior than `node-http2`, or vice-versa.
fix
Explicitly decide which module you intend to use. For the native Node.js module: `const http2 = require('node:http2'); http2.createSecureServer(...)`. For this legacy `node-http2` package: `const http2 = require('node-http2'); http2.createServer(...)`. Pay attention to whether `createSecureServer` (native) or `createServer` (this package) is expected, and the required options.
SSL_CTX_set_alpn_protos failed
HTTP/2 relies heavily on TLS and ALPN for secure connections. This error can indicate issues with TLS setup, incorrect certificate/key files, or an incompatibility with the Node.js crypto module or OpenSSL version, especially given the age of this library.
fix
Double-check your `key` and `cert` file paths and permissions. Ensure they are valid TLS certificates. If using an older Node.js, update to a newer version (preferably one with native http2 support) to get modern TLS features. If using `node-http2`, ensure Node.js >= 5.0 for ALPN.
Upgrade
Version history
4.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
node-http2 — npm install node-http2 · libregistry