Puppeteer-extra: Stealth example not working

Created on 12 Feb 2019  路  8Comments  路  Source: berstend/puppeteer-extra

// puppeteer-extra is a drop-in replacement for puppeteer,
// it augments the installed puppeteer with plugin functionality
const puppeteer = require("puppeteer-extra")
// register plugins through `.use()`
puppeteer.use(
  require("puppeteer-extra-plugin-anonymize-ua")({ makeWindows: true })
)
puppeteer.use(require("puppeteer-extra-plugin-stealth")())

// usage as normal
puppeteer.launch().then(async browser => {
  const page = await browser.newPage()
  await page.goto("https://httpbin.org/headers", {
    waitUntil: "domcontentloaded"
  })
  const content = await page.content()
  console.log("content:", content) // => (..) User-Agent: (..) Windows NT 10.0
  await browser.close()
})

When I use that piece of code it doesn't work, giving me this error

C:\Users\Dan\Desktop\nodetests>node index

          A plugin listed 'puppeteer-extra-plugin-stealth/evasions/chrome.runtime' as dependency,
          which is currently missing. Please install it:

          yarn add puppeteer-extra-plugin-stealth

          Note: You don't need to require the plugin yourself,
          unless you want to modify it's default settings.

(node:38324) UnhandledPromiseRejectionWarning: TypeError: Class extends value #<Object> is not a constructor or null
    at Object.<anonymous> (C:\Users\Dan\node_modules\puppeteer-extra-plugin-stealth\evasions\chrome.runtime\index.js:10:22)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at PuppeteerExtra.resolvePluginDependencies (C:\Users\Dan\node_modules\puppeteer-extra\index.js:264:15)
    at PuppeteerExtra.launch (C:\Users\Dan\node_modules\puppeteer-extra\index.js:96:10)
(node:38324) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:38324) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

When I remove puppeteer.use(require("puppeteer-extra-plugin-stealth")())it works fine

Most helpful comment

Keep in mind that the example script you're using is making use of two plugins that need to be installed.

So next to yarn add puppeteer puppeteer-extra you also need to run yarn add puppeteer-extra-plugin-stealth puppeteer-extra-plugin-anonymize-ua for the example script to work.

Maybe I should make that clearer in the readme.

All 8 comments

Whoops, I have an idea why that might be - I rewrote the base plugin in typescript and changed the exports to be named. Let me check!

@AsianPotato could you run yarn list puppeteer-extra-* real quick and paste the output here? thanks!

Nevermind I found the issue - fixing it now 馃槃

Thanks a lot for the quick reply!

@AsianPotato I just published [email protected] with a fix, everything should work now.

Rerunning yarn add puppeteer-extra-plugin-stealth in your project should be enough to fetch the new version.

Apologies for that bug, I rewrote parts in typescript just yesterday and for some mysterious reasons the CI tests didn't complain about this issue. 馃槃

Keep in mind that the example script you're using is making use of two plugins that need to be installed.

So next to yarn add puppeteer puppeteer-extra you also need to run yarn add puppeteer-extra-plugin-stealth puppeteer-extra-plugin-anonymize-ua for the example script to work.

Maybe I should make that clearer in the readme.

@AsianPotato thanks a lot for the issue, I've improved the main example to be much clearer for the next person. :-)

Hi
I have this problem with puppeteer-extra-plugin-stealth version 2.4.9
If I execute my software in cli with npm start, all work fine but if I create an exe with pkg I will receive this error:

      A plugin listed 'puppeteer-extra-plugin-stealth/evasions/chrome.runtime' as dependency,
      which is currently missing. Please install it:

      yarn add puppeteer-extra-plugin-stealth

      Note: You don't need to require the plugin yourself,
      unless you want to modify it's default settings.

How can I fix this?

thank you @berstend

Was this page helpful?
0 / 5 - 0 ratings

Related issues

engineswap picture engineswap  路  7Comments

LitMSCTBB picture LitMSCTBB  路  5Comments

moltar picture moltar  路  9Comments

AdityaAnand1 picture AdityaAnand1  路  9Comments

prescience-data picture prescience-data  路  5Comments