puppeteer-extra icon indicating copy to clipboard operation
puppeteer-extra copied to clipboard

[Bug]

Open teddis opened this issue 1 year ago • 4 comments

I'm attempting to test puppeteer-extra with my NextJS/Typescript ^5.2.2 server and accompanying scraper. I'm using PyCharm IDE which has been fine for my Node projects. When I import the following, the IDE marks them with problems:

image

  1. I get TS2339: Property use does not exist on type in the first use of puppeteer.use(StealthPlugin()).
  2. I get TS2349: This expression is not callable on second use(AdblockerPlugin()) reference.

Suppressing these with // @ts-ignore covers over the IDE problem (red gone) and runtime appears to work. I'm still rather new to dealing with these kinds of problems, didn't expect this and not sure if there's a simple fix.

Versions

System: OS: macOS 13.5.1 CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz Memory: 940.78 MB / 32.00 GB Shell: 3.2.57 - /bin/bash

Binaries: Node: 18.17.0 - ~/.nvm/versions/node/v18.17.0/bin/node Yarn: 1.22.19 - ~/.nvm/versions/node/v18.17.0/bin/yarn npm: 9.6.7 - ~/.nvm/versions/node/v18.17.0/bin/npm

npmPackages: puppeteer-core: ^21.1.0 => 21.1.0 puppeteer-extra: ^3.3.6 => 3.3.6 puppeteer-extra-plugin-adblocker: ^2.13.6 => 2.13.6 puppeteer-extra-plugin-stealth: ^2.11.2 => 2.11.2

teddis avatar Sep 10 '23 21:09 teddis

Yep, I'm having the same. I used this workaround:

import _AdblockerPlugin from "puppeteer-extra-plugin-adblocker";
const AdblockerPlugin = _AdblockerPlugin.default;
puppeteer.use(AdblockerPlugin());

For what it's worth, I also bumped into #748.


package.json:

{
	"type": "module",
	"dependencies": {
		"puppeteer": "^21.5.1",
		"puppeteer-extra": "^3.3.6",
		"puppeteer-extra-plugin-adblocker": "^2.13.6",
		"typescript": "^5.2.2"
	},
	"volta": {
		"node": "18.17.0"
	}
}

tsconfig.json:

{
	"compilerOptions": {
		"strict": true,
		"target": "es6",
		"lib": ["es6", "DOM"],
		"module": "NodeNext",
		"moduleResolution": "NodeNext"
	}
}

hdodov avatar Nov 11 '23 10:11 hdodov

I just found out that if I remove "type": "module" from my package.json, I no longer experience the issue.

hdodov avatar Nov 11 '23 10:11 hdodov

just change puppeteer into puppeteerExtra

import puppeterExtra from 'puppeteerExtra'

and use like puppeteerExtra.use(StealthPlugin());

abaytek avatar Aug 16 '24 12:08 abaytek

just change puppeteer into puppeteerExtra

import puppeterExtra from 'puppeteer-extra'

and use like puppeteerExtra.use(StealthPlugin());

abaytek avatar Aug 16 '24 12:08 abaytek