{"id":48740,"library":"node-fetch-commonjs","title":"node-fetch (CommonJS version)","description":"A CommonJS-compatible fork of node-fetch v3.x that brings the WHATWG Fetch API to Node.js. This package provides the same API as node-fetch v3.3.1 but compiled to CommonJS, allowing require() usage and avoiding the ExperimentalWarning about 'stream/web'. It supports Node.js ^12.20.0, ^14.13.1, or >=16.0.0 and ships TypeScript type definitions. Useful for projects that require CommonJS modules or run on older Node.js versions that don't support node: prefix requires.","status":"active","version":"3.3.2","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/proteriax/node-fetch-cjs","tags":["javascript","fetch","http","promise","request","curl","wget","xhr","whatwg","typescript"],"install":[{"cmd":"npm install node-fetch-commonjs","lang":"bash","label":"npm"},{"cmd":"yarn add node-fetch-commonjs","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-fetch-commonjs","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default import works directly; no need for .default in CommonJS.","wrong":"const fetch = require('node-fetch-commonjs').default","symbol":"default (fetch)","correct":"import fetch from 'node-fetch-commonjs'"},{"note":"Named export works in both ESM and CJS.","wrong":"const { Headers } = require('node-fetch-commonjs')","symbol":"Headers","correct":"import { Headers } from 'node-fetch-commonjs'"},{"note":"Available as named export.","wrong":null,"symbol":"Request","correct":"import { Request } from 'node-fetch-commonjs'"},{"note":"Available as named export.","wrong":null,"symbol":"Response","correct":"import { Response } from 'node-fetch-commonjs'"},{"note":"For type checking fetch errors.","wrong":null,"symbol":"FetchError","correct":"import { FetchError } from 'node-fetch-commonjs'"}],"quickstart":{"code":"import fetch from 'node-fetch-commonjs';\n\nasync function main() {\n  try {\n    const response = await fetch('https://api.example.com/data', {\n      method: 'GET',\n      headers: { 'Accept': 'application/json' }\n    });\n    if (!response.ok) {\n      throw new Error(`HTTP error! status: ${response.status}`);\n    }\n    const data = await response.json();\n    console.log(data);\n  } catch (error) {\n    console.error('Fetch failed:', error);\n  }\n}\n\nmain();","lang":"typescript","description":"Shows basic fetch usage with error handling for non-ok responses."},"warnings":[{"fix":"Check node-fetch documentation for known limitations.","message":"node-fetch-commonjs does not support all WHATWG Fetch API features (e.g., abort controller is supported but some edge cases differ)","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Use global fetch available in Node >=18, or import from 'node:fetch'.","message":"The Fetch API is now built-in in Node.js 18+. Consider using native fetch instead.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Use import() syntax or ensure package is fully CommonJS.","message":"CommonJS require() may not correctly resolve ESM-only subpath exports.","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"search_vec":"'12.20.0':51 '14.13.1':52 '16.0.0':54 'allow':39 'api':21,29 'avoid':43 'bring':17 'commonj':4,8,38,65 'commonjs-compat':7 'compat':9 'compil':36 'curl':85 'definit':59 'experimentalwarn':45 'fetch':3,14,20,33,81 'fork':10 'http':82 'javascript':80 'modul':66 'node':2,13,32,77 'node-fetch':1,12,31 'node.js':23,50,71 'older':70 'packag':25 'prefix':78 'project':62 'promis':83 'provid':26 'request':84 'requir':40,64,79 'run':68 'ship':56 'stream/web':47 'support':49,76 'type':58 'typescript':57,89 'usag':41 'use':60 'v3.3.1':34 'v3.x':15 'version':5,72 'wget':86 'whatwg':19,88 'xhr':87","created_at":"2026-06-07T16:58:12.853149+00:00","updated_at":"2026-06-07T16:58:12.853149+00:00","problems":[{"fix":"Use node-fetch-commonjs instead of node-fetch to avoid the warning.","cause":"node-fetch v3 triggers this warning on some Node versions; node-fetch-commonjs suppresses it","error":"ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time"},{"fix":"Run 'npm install node-fetch-commonjs' or 'yarn add node-fetch-commonjs'","cause":"Package not installed or not in node_modules","error":"Cannot find module 'node-fetch-commonjs'"},{"fix":"Add 'import fetch from \"node-fetch-commonjs\"' at the top of your file.","cause":"Using an older version of Node that doesn't have native fetch and forgetting to import","error":"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/proteriax/node-fetch-cjs#readme","github":"ssh://git@github.com/proteriax/node-fetch-cjs","docs":null,"changelog":null,"pypi":null,"npm":"node-fetch-commonjs","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-07","next_check":"2026-09-05","install_tag":null}}