When using puppeteer-extra-plugin-stealth with electron-forge with a webpack template, when you run npm start you will get the error.

App threw an error during load
Error: Cannot find module 'is-plain-object'

I have just booted up a very basic electron-forge app based on quick start guide on their site.

Started the app and its working good. Installed the following.

  • playwright
  • playwright-extra
  • puppeteer-extra-plugin-stealth

and just by importing puppeteer-extra-plugin-stealth is enough to trigger the error on npm start.

const { chromium } = require("playwright-extra");
const stealth = require("puppeteer-extra-plugin-stealth")();

... additional codes below ...

I tried various remedies on the internet

  • added externals to webpack.main.config.js only, webpack.renderer.config.js only and both webpack.main.config.js and webpack.renderer.config.js and it doesn't work.
  externals: {
    playwright: "require('playwright')",
    "playwright-extra": "require('playwright-extra')",
    "puppeteer-extra-plugin-stealth":
      "require('puppeteer-extra-plugin-stealth')",
  },

Adding this yield another different error saying

Error: Cannot find module 'require('playwright-extra')'
  • Added externals config on forge.config.js
  configureWebpack: {
    externals: {
      playwright: "require('playwright')",
      "playwright-extra": "require('playwright-extra')",
      "puppeteer-extra-plugin-stealth":
        "require('puppeteer-extra-plugin-stealth')",
    },
  },

Throws the original error

App threw an error during load
Error: Cannot find module 'is-plain-object'

Hope anyone can help me with this.


Note: I have tested using raw electron app (without electron-forge) and electron-forge without webpack template and its working good on those instances.

This is only exclusive to when using webpack as template for electron forge.


package.json file

{
  "name": "electron-forge-webpack",
  "productName": "electron-forge-webpack",
  "version": "1.0.0",
  "description": "My Electron application description",
  "main": ".webpack/main",
  "scripts": {
    "start": "electron-forge start",
    "package": "electron-forge package",
    "make": "electron-forge make",
    "publish": "electron-forge publish",
    "lint": "echo \"No linting configured\""
  },
  "devDependencies": {
    "@electron-forge/cli": "^7.3.0",
    "@electron-forge/maker-deb": "^7.3.0",
    "@electron-forge/maker-rpm": "^7.3.0",
    "@electron-forge/maker-squirrel": "^7.3.0",
    "@electron-forge/maker-zip": "^7.3.0",
    "@electron-forge/plugin-auto-unpack-natives": "^7.3.0",
    "@electron-forge/plugin-fuses": "^7.2.0",
    "@electron-forge/plugin-webpack": "^7.3.0",
    "@electron/fuses": "^1.7.0",
    "@vercel/webpack-asset-relocator-loader": "1.7.3",
    "css-loader": "^6.0.0",
    "electron": "29.1.0",
    "node-loader": "^2.0.0",
    "style-loader": "^3.0.0"
  },
  "keywords": [],
  "author": {
    "name": "John Doe",
    "email": "[email protected]"
  },
  "license": "MIT",
  "dependencies": {
    "@playwright/browser-chromium": "^1.42.0",
    "electron-squirrel-startup": "^1.0.0",
    "playwright": "^1.42.0",
    "playwright-extra": "^4.3.6",
    "puppeteer-extra-plugin-stealth": "^2.11.2"
  }
}
0

There are 0 best solutions below