当将
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
就足以在 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"
}
}
嘿,我遇到了同样的问题,有什么解决方案可以提供帮助吗?