Registry / testing / puppeteer-fetch

puppeteer-fetch

JSON →
library0.3.1jsnpmunverified

puppeteer-fetch is a Node.js library that wraps Puppeteer to provide a fetch-like API for HTTP requests, mimicking the node-fetch interface but using Puppeteer as the underlying driver. This enables scraping of JavaScript-rendered pages and bypassing WAF protections. Current stable version is 0.3.1, released occasionally with minimal updates. It ships TypeScript types and requires Node >=14.15. Key differentiators: it combines the simplicity of fetch with Puppeteer's ability to handle dynamic content and anti-bot measures.

npm install puppeteer-fetch
INSTALL
IMPORT
SIG · PUPPETEER-FETCH
P
puppeteer-fetch
testingjavascriptv0.3.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.

default (main export)
import fetch from 'puppeteer-fetch'
const fetch = require('puppeteer-fetch')
The default export is a function that mimics node-fetch. In TypeScript, use default import: import fetch from 'puppeteer-fetch'. In CommonJS, use require('puppeteer-fetch').default.
default (CommonJS)
const fetch = require('puppeteer-fetch').default
const fetch = require('puppeteer-fetch')
In CommonJS, the default export is not directly available; you must access .default.
IPuppeteerConfig (type)
import type { IPuppeteerConfig } from 'puppeteer-fetch'
TypeScript users can import the IPuppeteerConfig interface for type-checking puppeteer options.

Demonstrates basic GET request with puppeteer-fetch, using async/await and JSON parsing.

import fetch from 'puppeteer-fetch'; (async () => { try { const response = await fetch('https://jsonplaceholder.typicode.com/posts/1'); const data = await response.json(); console.log(data); } catch (error) { console.error('Request failed:', error); } })();
Debug
Known issues
breakingThe default export behavior changed between versions: in older docs, require('puppeteer-fetch') returns the fetch function, but the actual default export is .default.
fix
Ensure you use .default when importing with CommonJS: const fetch = require('puppeteer-fetch').default;
affects: <0.3.0
gotchaPuppeteer is a peer dependency; must be installed separately. Missing Puppeteer will cause runtime errors.
fix
Run: npm install puppeteer
affects: >=0.1.0
gotchaThe response object is a Puppeteer HTTPResponse, not a standard fetch Response. Properties like .ok, .status, .headers work, but methods like .json() and .text() are simulated and may not behave identically.
fix
Use standard fetch properties but test edge cases like .clone() which may not be available.
affects: >=0.1.0
deprecatedThe puppeteerConfig option in older docs used launchOptions: {...}, but newer versions expect a flat structure. Check changelog.
fix
Use the latest API: fetch(url, fetchOptions, { puppeteerConfig: { ... } })
affects: <0.3.0
Errors
Common errors & fixes
TypeError: require(...).default is not a function
Using require('puppeteer-fetch') without .default, or using an older version where .default was not present.
fix
Use const fetch = require('puppeteer-fetch').default; or switch to ES module import.
Error: Cannot find module 'puppeteer'
Puppeteer is not installed. It is a peer dependency.
fix
Install puppeteer: npm install puppeteer
TypeError: fetch is not a function
Incorrect import style, e.g., using default import on a CommonJS module without setting 'esModuleInterop'.
fix
If using ES modules with CommonJS package, use import fetch from 'puppeteer-fetch' (with .default omitted in TypeScript with esModuleInterop). Otherwise use const fetch = require('puppeteer-fetch').default;
Upgrade
Version history
0.3.1latest on npm
Audit
Dependencies
puppeteerrequiredprovides browser automation for HTTP requests
Agent activity
10 hits · last 30 days
node
8
Amazon
1
Bingbot
1
Resources
puppeteer-fetch — npm install puppeteer-fetch · libregistry