1
votes

I am developing Desktop App(windows/mac) using Electronjs. I was trying to implement auto-update feature using electron-updater since I am using electron-builder for the building.

I am able to generate .exe file for my app but when trying to install, it's throwing an error: "Can not find module 'debug'". Please find attached screenshotAuto-updater-error.

Without electron-updater implementation, my app is running fine. When I am importing autoUpdator in my index.js, started getting that error. I am using autoUpdator as below:

const {autoUpdater} = require("electron-updater");
autoUpdater.on('update-downloaded', (ev, info) => {
  setTimeout(function() {
    autoUpdater.quitAndInstall();  
  }, 5000)
})
app.on('ready', ()=> {
  autoUpdater.checkForUpdates();
});

Please find the libraries description below:

  • "electron-updater": "^4.0.6"
  • "electron": "^3.0.6"
  • "electron-builder": "^20.38.4"

I followed below links:

Electron builder Auto Update

electron builder using local server

I am new to the Electron js actively looking for your support.

As asked please find my build configuration below:

"build": {
    "appId": "com.****.*****",
    "productName": "********",
    "directories": {
      "output": "build"
    },
    "publish": [
      {
        "provider": "generic",
        "url": "http://127.0.0.1:4080/"
      }
    ],
    "nsis": {
      "oneClick": false,
      "perMachine": true,
      "allowElevation": true,
      "allowToChangeInstallationDirectory": true,
      "deleteAppDataOnUninstall": true,
      "createDesktopShortcut": true
    },
    "win": {
      "target": "nsis"
    },
    "files": [
      "!**/.vscode",
      "!**/build",
      "!**/config",
      "!**/assets/data",
      "!**/src"
    ],
    "extraResources": [
      {
        "from": "src/assets/data",
        "to": "dist/assets/data",
        "filter": "database*"
      }
    ]
  },
1
What happens when you run it in development mode? Does it throw any error there?Rahul Raval
Can you share your configs for the build?Batajus
@RahulRaval, In development mode it runs fine. No error.Rahul Upadhyay
Try it without generating the .asar file.Rahul Raval

1 Answers

1
votes

The line "!**/src" in your exclude list is the culprit.

  1. Many node modules will have "src" folders which have to be packaged/bundled along with your application source code.
  2. If you observe "debug" module folder under "node_modules" it has a "src" folder which has been excluded by above rule.

Suggestion: If you have your apps source folder as "src", rename it to something else like "source" (which is in your control), but ensure you don't exclude "src" folders of node_modules (renaming these is not in your control as it could break the module's integrity and they get overwritten on fresh npm install also)