Registry / devops / fetch-undici-polyfill

fetch-undici-polyfill

JSON →
library1.2.1jsnpmunverified

Polyfill for the global fetch API in Node.js using the undici HTTP client. Version 1.2.1, stable. Provides a lightweight, standards-compliant fetch implementation for Node.js versions that lack it, with automatic proxy support via environment variables. Different from other fetch polyfills by being based on undici, which is the official Node.js HTTP client for HTTP/1.1 and HTTP/2.

npm install fetch-undici-polyfill
INSTALL
IMPORT
SIG · FETCH-UNDICI-POLYF
F
fetch-undici-polyfill
devopsjavascriptv1.2.1
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.

void
import 'fetch-undici-polyfill'
import fetch from 'fetch-undici-polyfill'
Side-effect import: polyfills global fetch, no exports.
void
require('fetch-undici-polyfill')
const fetch = require('fetch-undici-polyfill')
CJS require also side-effect only.
global fetch
fetch('https://example.com')
globalThis.fetch('...')
fetch is added to global scope automatically.

Demonstrates importing the polyfill as a side-effect and using the global fetch to make an HTTP request.

import 'fetch-undici-polyfill'; async function main() { const response = await fetch('https://jsonplaceholder.typicode.com/posts/1'); const data = await response.json(); console.log(data); } main().catch(console.error);
Debug
Known issues
gotchaImport is a side-effect, not a default export. Do not assign to variable.
fix
Use `import 'fetch-undici-polyfill'` without assignment.
affects: >=1.0.0
gotchaOnly polyfills fetch in Node.js, not browser. No effect in browser environments.
fix
Use only in Node.js scripts; for browser, use native fetch or a different polyfill.
affects: >=1.0.0
deprecatedUndici v6 made breaking changes. Ensure compatible version installed.
fix
Pin undici to v5 if using older node versions, or update to latest fetch-undici-polyfill.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'undici'
undici is a peer dependency not installed
fix
Run `npm install undici` to install the required peer dependency.
ReferenceError: fetch is not defined
Polyfill not imported before use
fix
Add `import 'fetch-undici-polyfill'` at the top of your entry file.
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies
undicirequiredCore HTTP client used for fetch implementation
Agent activity
2 hits · last 30 days
node
2
Resources
fetch-undici-polyfill — npm install fetch-undici-polyfill · libregistry