使用带有 webpack 模板的 electro-forge 的 puppeteer-extra-plugin-stealth 时找不到模块“is-plain-object”错误

问题描述 投票:0回答:1

当将

puppeteer-extra-plugin-stealth
electron-forge
webpack
模板一起使用时,当您运行
npm start
时,您将收到错误。

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

我刚刚根据他们网站上的快速入门指南启动了一个非常基本的电子锻造应用程序。

启动应用程序并且运行良好。 安装了以下内容。

  • 剧作家
  • 剧作家额外
  • puppeteer-extra-plugin-stealth

并且只需导入

puppeteer-extra-plugin-stealth
就足以在 npm start 上触发错误。

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

... additional codes below ...

我在网上尝试了各种补救措施

  • 仅向
    webpack.main.config.js
    、仅
    webpack.renderer.config.js
    以及
    webpack.main.config.js
    webpack.renderer.config.js
    添加外部组件,但不起作用。
  externals: {
    playwright: "require('playwright')",
    "playwright-extra": "require('playwright-extra')",
    "puppeteer-extra-plugin-stealth":
      "require('puppeteer-extra-plugin-stealth')",
  },

添加这个会产生另一个不同的错误说

Error: Cannot find module 'require('playwright-extra')'
  • forge.config.js
  • 上添加了外部配置
  configureWebpack: {
    externals: {
      playwright: "require('playwright')",
      "playwright-extra": "require('playwright-extra')",
      "puppeteer-extra-plugin-stealth":
        "require('puppeteer-extra-plugin-stealth')",
    },
  },

抛出原来的错误

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

希望任何人都可以帮助我。


注: 我已经使用原始电子应用程序(没有 Electron-Forge)和没有 Webpack 模板的 Electron-Forge 进行了测试,并且它在这些实例上运行良好。

这仅适用于使用 webpack 作为 Electron Forge 模板时。


package.json 文件

{
  "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"
  }
}
webpack electron playwright electron-forge puppeteer-extra-plugin-stealth
1个回答
0
投票

嘿,我遇到了同样的问题,有什么解决方案可以提供帮助吗?

© www.soinside.com 2019 - 2024. All rights reserved.