Registry / devops / extra-fetch

extra-fetch

JSON →
library5.2.0jsnpmunverified

A drop-in replacement for the global fetch API in Node.js, providing enhanced features such as HTTP/2 support, logging, and compatibility with experimental fetch implementations. Version 5.2.0 requires Node.js >=22 and ships TypeScript types. The library exports the standard fetch, Headers, Request, Response, FormData, AbortController, Blob, and EventSource, with HTTP/2 enabled by default and configurable logging via environment variables. It differentiates itself by offering a seamless upgrade path for Node.js fetch with minimal configuration.

npm install extra-fetch
INSTALL
IMPORT
SIG · EXTRA-FETCH
E
extra-fetch
devopsjavascriptv5.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

fetch
import { fetch } from 'extra-fetch'
import fetch from 'extra-fetch'
Named export, not default. ESM-only; this package does not support CommonJS require.
Headers
import { Headers } from 'extra-fetch'
const { Headers } = require('extra-fetch')
Named export. Because the package is ESM-only, require() will throw an error.
Response
import { Response } from 'extra-fetch'
import Response from 'extra-fetch'
Named export; not default. Use named import syntax.
EventSource
import { EventSource } from 'extra-fetch'
Named export. Available since v5.0.0.

Demonstrates basic usage of enhanced fetch with custom headers and async/await error handling.

import { fetch, Headers, Response } from 'extra-fetch'; async function main() { const url = 'https://api.example.com/data'; const headers = new Headers(); headers.set('Content-Type', 'application/json'); headers.set('Authorization', `Bearer ${process.env.API_KEY ?? ''}`); const response = await fetch(url, { method: 'GET', headers }); if (!response.ok) { console.error('Request failed:', response.statusText); return; } const data = await response.json(); console.log('Data:', data); } main().catch(console.error);
Debug
Known issues
breakingRequires Node.js >=22. Older Node.js versions are not supported.
fix
Upgrade Node.js to v22 or later.
affects: >=5.0.0
breakingESM-only package. CommonJS require() does not work.
fix
Use import syntax instead. If you must use require, use dynamic import: const { fetch } = await import('extra-fetch')
affects: >=5.0.0
gotchaHTTP/2 is enabled by default in Node.js. This may cause unexpected behavior with HTTP/1.1-only servers.
fix
Set environment variable EXTRA_FETCH_HTTP2=false to disable HTTP/2.
affects: >=5.0.0
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
Running in a CommonJS environment without proper ESM configuration.
fix
Ensure your project is configured as ESM (type: 'module' in package.json) or use dynamic import.
TypeError: Class constructor Headers cannot be invoked without 'new'
Using Headers as a function without the 'new' keyword, or incorrect import.
fix
Ensure you import Headers as a named import and use 'new Headers()'.
Upgrade
Version history
5.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

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