{"id":40771,"library":"cross-fetch-ponyfill","title":"cross-fetch-ponyfill","description":"A lightweight fetch ponyfill that only provides a fetch polyfill in Node.js environments. In browsers, it uses the native fetch API without modification. This approach avoids unnecessary polyfilling in browsers and ensures minimal overhead. Version 1.0.3 is the latest stable release. The package is updated infrequently, with a simple API that exports a single fetch function. It differentiates itself from other cross-platform fetch libraries by being a true ponyfill (no side effects or global pollution) and only targeting Node.js for polyfilling.","status":"active","version":"1.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/ThaUnknown/cross-fetch-ponyfill","tags":["javascript","fetch","ponyfill","node","browser"],"install":[{"cmd":"npm install cross-fetch-ponyfill","lang":"bash","label":"npm"},{"cmd":"yarn add cross-fetch-ponyfill","lang":"bash","label":"yarn"},{"cmd":"pnpm add cross-fetch-ponyfill","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used only in Node.js to polyfill fetch; not bundled in browser builds.","package":"whatwg-fetch","optional":true}],"imports":[{"note":"The default export is a fetch function. A named export is not available.","wrong":"import { fetch } from 'cross-fetch-ponyfill'","symbol":"default","correct":"import fetch from 'cross-fetch-ponyfill'"},{"note":"CommonJS users must use default require; destructuring will result in undefined.","wrong":"const { fetch } = require('cross-fetch-ponyfill')","symbol":"CommonJS","correct":"const fetch = require('cross-fetch-ponyfill')"},{"note":"TypeScript users should use default import; namespace import is not typed correctly.","wrong":"import * as fetch from 'cross-fetch-ponyfill'","symbol":"TypeScript","correct":"import fetch from 'cross-fetch-ponyfill'"}],"quickstart":{"code":"import fetch from 'cross-fetch-ponyfill';\n\nasync function main() {\n  const response = await fetch('https://api.example.com/data');\n  const data = await response.json();\n  console.log(data);\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Shows basic usage: importing fetch as default and making a GET request with async/await."},"warnings":[{"fix":"Import the fetch function and use it directly. Do not expect global.fetch to be available.","message":"This is a ponyfill, not a polyfill. It does not modify global fetch in any environment.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider alternatives like 'node-fetch' (for Node 18+ native fetch is stable) or native fetch in modern browsers.","message":"The 'whatwg-fetch' dependency is only installed in Node.js environments; in browsers it is not used. However, whatwg-fetch itself is not actively maintained and may have bugs.","severity":"deprecated","affected_versions":"<=1.0.3"},{"fix":"Set 'moduleResolution' to 'node' or 'node16' in tsconfig.json.","message":"TypeScript users must ensure their tsconfig 'moduleResolution' is set to 'node' or 'node16' to resolve the default export correctly.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'1.0.3':40 'api':25,54 'approach':29 'avoid':30 'browser':19,34,92 'cross':2,67 'cross-fetch-ponyfil':1 'cross-platform':66 'differenti':62 'effect':78 'ensur':36 'environ':17 'export':56 'fetch':3,7,13,24,59,69,89 'function':60 'global':80 'infrequ':50 'javascript':88 'latest':43 'librari':70 'lightweight':6 'minim':37 'modif':27 'nativ':23 'node':91 'node.js':16,85 'overhead':38 'packag':47 'platform':68 'pollut':81 'polyfil':14,32,87 'ponyfil':4,8,75,90 'provid':11 'releas':45 'side':77 'simpl':53 'singl':58 'stabl':44 'target':84 'true':74 'unnecessari':31 'updat':49 'use':21 'version':39 'without':26","created_at":"2026-06-04T18:49:10.171057+00:00","updated_at":"2026-06-04T18:49:10.171057+00:00","problems":[{"fix":"Install @types/cross-fetch-ponyfill (if available) or declare the module: declare module 'cross-fetch-ponyfill';","cause":"TypeScript cannot find the module because it lacks types.","error":"Cannot find module 'cross-fetch-ponyfill' or its corresponding type declarations."},{"fix":"Use import fetch from 'cross-fetch-ponyfill' (default import) instead of import { fetch } from 'cross-fetch-ponyfill'.","cause":"Importing the named export { fetch } instead of the default export.","error":"TypeError: fetch is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/ThaUnknown/cross-fetch-ponyfill#readme","github":"https://github.com/ThaUnknown/cross-fetch-ponyfill","docs":null,"changelog":null,"pypi":null,"npm":"cross-fetch-ponyfill","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}