Open
Description
Describe the bug
.mts compilation fails importing puppeteer-extra but not puppeteer.
Code Snippet
With these packages installed:
"puppeteer": "^24.9.0",
"puppeteer-extra": "^3.3.6",
This tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
}
And this tsconfig.scripts.json:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "NodeNext",
"target": "es2020",
"moduleResolution": "node",
"noEmit": true
},
"include": ["scripts"]
}
And my-script.mts containing this:
import puppeteer from 'puppeteer';
import UserAgent from 'user-agents';
async function scrape() {
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
await page.setUserAgent(UserAgent.toString())
await page.goto("https://www.google.com", { waitUntil: 'networkidle0', timeout: 30000 });
const data = await page.evaluate(() => {
console.log("Finished!")
});
await browser.close();
}
scrape();
This command:
TS_NODE_PROJECT=tsconfig.scripts.json node --loader ts-node/esm scripts/my-script.mts
runs successfully.
However, if I change
import puppeteer from 'puppeteer';
to
import puppeteer from 'puppeteer-extra';
it fails:
node:internal/modules/run_main:129
triggerUncaughtException(
^
[Object: null prototype] {
[Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]]
}
Versions
System:
OS: macOS 15.4.1
CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
Memory: 292.35 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.14.0 - /usr/local/bin/node
npm: 10.7.0 - /usr/local/bin/npm
pnpm: 10.11.0 - ~/Library/pnpm/pnpm
npmPackages:
puppeteer: ^24.9.0 => 24.9.0
puppeteer-extra: ^3.3.6 => 3.3.6
puppeteer-extra-plugin-stealth: ^2.11.2 => 2.11.2