{"id":27987,"library":"node-fetch-with-proxy","title":"node-fetch-with-proxy","description":"Thin wrapper around node-fetch that transparently uses HTTP_PROXY/HTTPS_PROXY environment variables for proxy support. Version 0.1.6, stable but low update cadence (last update 2019). Key differentiator: drop-in replacement for node-fetch that requires no code changes — just set proxy env vars. Unlike node-fetch's native proxy options, it uses proxy-agent under the hood for comprehensive protocol support (http, https, socks).","status":"active","version":"0.1.6","language":"javascript","source_language":"en","source_url":"https://github.com/snoguchi/node-fetch-with-proxy","tags":["javascript","http","fetch","proxy"],"install":[{"cmd":"npm install node-fetch-with-proxy","lang":"bash","label":"npm"},{"cmd":"yarn add node-fetch-with-proxy","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-fetch-with-proxy","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"wrapper around node-fetch; fetches HTTP requests","package":"node-fetch","optional":false},{"reason":"handles proxy connections via environment variables","package":"proxy-agent","optional":false}],"imports":[{"note":"Default import works in both CJS and ESM; CJS require also works.","wrong":"const fetch = require('node-fetch-with-proxy')","symbol":"fetch","correct":"import fetch from 'node-fetch-with-proxy'"},{"note":"Module exports a single fetch function.","wrong":"","symbol":"default","correct":"import fetch from 'node-fetch-with-proxy'"},{"note":"Headers, Request, Response are not re-exported; import from node-fetch directly.","wrong":"import { Headers } from 'node-fetch-with-proxy'","symbol":"Headers","correct":"import { Headers } from 'node-fetch'"}],"quickstart":{"code":"import fetch from 'node-fetch-with-proxy';\nprocess.env.HTTP_PROXY = process.env.HTTP_PROXY || 'http://proxy.example.com:8080';\n\nasync function main() {\n  try {\n    const res = await fetch('http://httpbin.org/get');\n    const data = await res.json();\n    console.log(data);\n  } catch (err) {\n    console.error('Fetch failed:', err.message);\n  }\n}\nmain();","lang":"javascript","description":"Sets proxy via environment variable and performs a GET request to httpbin."},"warnings":[{"fix":"Set NO_PROXY env var (comma-separated list of hostnames) to exclude from proxy.","message":"HTTP_PROXY is used for both http and https requests; use NO_PROXY to bypass proxy for specific hosts.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Set env vars before importing the package.","message":"Environment variables are only read once at import time; changing them later has no effect.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use node-fetch v2 or check compatibility; consider using native fetch (Node 18+).","message":"node-fetch v3 is ESM-only; this wrapper may not be compatible with node-fetch v3 due to CJS dependencies.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Consider native fetch or alternatives like undici with proxy support.","message":"Package last updated in 2019; no known issues but may lack modern node-fetch features.","severity":"deprecated","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Verify HTTP_PROXY value is correct and DNS resolves the proxy host.","cause":"Proxy hostname cannot be resolved.","error":"Error: getaddrinfo ENOTFOUND proxy.example.com"},{"fix":"Use 'import fetch from 'node-fetch-with-proxy'' (no curly braces).","cause":"Using named import instead of default import.","error":"TypeError: fetch is not a function"},{"fix":"Add 'type': 'module' in package.json or use require().","cause":"Trying to use ESM import in a CommonJS file without type:module.","error":"SyntaxError: Cannot use import statement outside a module"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}