Registry / devops / nodeify-fetch

nodeify-fetch

JSON →
library3.1.0jsnpmunverified

A Node.js package that wraps the Fetch API to provide a Readable stream interface for response bodies, using the native fetch in browsers and node-fetch in Node.js. Current stable version is 3.1.0. Since version 3.0, it is ESM-only; version 2.x is available for CommonJS. It differs from standard fetch by patching the .body property to return a Node.js Readable stream.

npm install nodeify-fetch
INSTALL
IMPORT
SIG · NODEIFY-FETCH
N
nodeify-fetch
devopsjavascriptv3.1.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 (default export)
import fetch from 'nodeify-fetch'
const fetch = require('nodeify-fetch')
Default export only. This is ESM-only since v3, so CommonJS require fails.
Response
import { Response } from 'nodeify-fetch'
const { Response } = require('nodeify-fetch')
Named export for the Response class. ESM-only.
Headers
import { Headers } from 'nodeify-fetch'
const Headers = require('nodeify-fetch').Headers
Named export for the Headers class. ESM-only.

Shows how to fetch a URL and read the response body as a Node.js Readable stream using nodeify-fetch.

import { promisify } from 'util'; import fetch from 'nodeify-fetch'; import { finished } from 'readable-stream'; async function main() { const res = await fetch('https://httpbin.org/anything'); if (!res.ok) { console.log(`Error ${res.statusText} (${res.status})`); return; } let data = ''; res.body.on('data', chunk => { data += chunk.toString(); }); await promisify(finished)(res.body); console.log('Response body:', data); } main();
Debug
Known issues
breakingSince version 3.0, nodeify-fetch is ESM-only. Using require() will throw.
fix
Use import instead of require, or stick with version 2.x.
affects: >=3.0
gotchaThe .body property returns a Readable stream, not the standard ReadableStream of the Fetch API.
fix
Use Node.js stream methods like .on('data') and .pipe() instead of ReadableStream methods like .getReader().
affects: >=1.0
gotchanodeify-fetch relies on node-fetch in Node.js, which does not support the full Fetch API (e.g., no ReadableStream).
fix
Check the node-fetch documentation for limitations.
affects: >=1.0
deprecatedThe node-fetch package is in maintenance mode and may be replaced by native Node.js fetch in future Node versions.
fix
Be prepared to switch to native fetch once Node.js stable fetch covers your needs.
affects: >=3.1
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /path/to/node_modules/nodeify-fetch/index.js require() of ES modules is not supported.
Attempting to require() the ESM-only package in a CommonJS context.
fix
Change to import syntax or downgrade to v2.x (npm install nodeify-fetch@2).
TypeError: res.body.getReader is not a function
Body is a Node.js Readable stream, not a Web ReadableStream.
fix
Use Node.js stream methods like on('data') or pipe() instead of ReadableStream API.
Cannot find module 'node-fetch'
node-fetch is a peer dependency and not installed automatically.
fix
Run: npm install node-fetch
Upgrade
Version history
3.1.0latest on npm
Audit
Dependencies
node-fetchrequiredUsed as the underlying fetch implementation in Node.js environments.
readable-streamrequiredProvides the Readable stream class for the patched .body property.
Agent activity
4 hits · last 30 days
node
4
Resources
nodeify-fetch — npm install nodeify-fetch · libregistry