WhatsApp Web JS无法与ElectronJS一起使用

kuhbmx9i  于 2023-05-15  发布在  Electron
关注(0)|答案(1)|浏览(222)

我在electronJS中用whatsapp-web.js做了一个项目。当我使用npm start调试时,它可以正常工作。但是当我用electron构建并安装(.exe)文件时,项目不工作。看起来人偶师没有逃跑。我该如何解决这个问题?注:我使用电子构建器为Windows构建应用程序。

{
  "name": "testapp",
  "version": "1.0.0",
  "description": "testapp",
  "main": "main.js",
  "scripts": {
    "start": "electron .",
    "build": "electron-builder"
  },
  "build": {
    "appId": "com.testapp.test",
    "productName": "testapp",
    "target": "NSIS",
    "nsis" : {
      "oneClick" : true,
      "allowToChangeInstallationDirectory" : false
    }
  },
  "author": "Udayan Basak",
  "license": "ISC",
  "devDependencies": {
    "electron": "^15.3.1",
    "electron-builder": "^22.14.5"
  },
  "dependencies": {
    "whatsapp-web.js": "^1.15.2"
  }
}

这是我的package.json数据。[再次强调:整个项目在开发模式下运行良好。导致生产层出错。]

const { Client } = require('whatsapp-web.js');
const {app, BrowserWindow, ipcMain, ipcRenderer } = require('electron') 
const client = new Client();
client.on('qr', (qr) => {
    win.webContents.send("qrcode", qr)
});

client.on('ready', () => {
    win.webContents.send("ready", "ready")
})
wfauudbj

wfauudbj1#

你能分享你的webpack配置吗?添加以下内容可能会有所帮助:

optimization: { minimize: false }

相关问题