5

I am looking for a simple way to build an electron app for macOS, from a linux machine.

Unfortunately, the electron-builder -m command doesn't work, here is the full output of the command:

electron-builder -m              
  • electron-builder  version=22.14.13 os=5.11.0-49-generic
  • loaded configuration  file=package.json ("build" field)
  • writing effective config  file=dist/builder-effective-config.yaml
⨯ Cannot find module 'dmg-license'
Require stack:
- /home/myUser/.nvm/versions/node/v16.13.0/lib/node_modules/electron-builder/node_modules/dmg-builder/out/dmgLicense.js
- /home/myUser/.nvm/versions/node/v16.13.0/lib/node_modules/electron-builder/node_modules/dmg-builder/out/dmg.js
- /home/myUser/.nvm/versions/node/v16.13.0/lib/node_modules/electron-builder/node_modules/dmg-builder/out/dmgUtil.js
- /home/myUser/.nvm/versions/node/v16.13.0/lib/node_modules/electron-builder/node_modules/app-builder-lib/out/macPackager.js
- /home/myUser/.nvm/versions/node/v16.13.0/lib/node_modules/electron-builder/node_modules/app-builder-lib/out/packager.js
- /home/myUser/.nvm/versions/node/v16.13.0/lib/node_modules/electron-builder/node_modules/app-builder-lib/out/index.js
- /home/myUser/.nvm/versions/node/v16.13.0/lib/node_modules/electron-builder/out/builder.js
- /home/myUser/.nvm/versions/node/v16.13.0/lib/node_modules/electron-builder/out/cli/cli.js
- /home/myUser/.nvm/versions/node/v16.13.0/lib/node_modules/electron-builder/cli.js  failedTask=build stackTrace=Error: Cannot find module 'dmg-license'

I have tried to install the dependency but it can be installed only on macOS...

I have also tried to install different versions, including 20.37.*,22.11.7, @latest (22.14.13) and @next

Is there any alternative way to build an app for macOS (the program I am using is for private purpose, so it's ok if it takes extra user steps to install) ?

Or any way to fix this dependency issue ?

TOPKAT
  • 6,667
  • 2
  • 44
  • 72
  • 1
    The dependency is not available for Linux systems. You can build with `zip` instead, since it just zips up the app. However, when I downloaded that artifact and tried to run it on macOS, it said the app is corrupted. So I'm guessing we have to use Mac systems to build - which sucks when Mac systems are so much more expensive. – ADTC Mar 26 '23 at 07:00

1 Answers1

3

Try:

npm i dmg-license

Perhaps this would be an alternative way to build. https://www.electronforge.io/

EDIT:

I had a similar error but my issue was I created subdirectories and the default package.json only included the top level directory in the build. The solution was to change in my electron package.json

  "build": {
    "appId": "com.example.capacitor-app",
    "productName": "Capacitor App",
    "files": [
      "assets/*",
      "build/*",
      "preloader.js",
      "plugins/*",
      "capacitor.config.json",
      "app/**"
    ],

To

  "build": {
    "appId": "com.example.capacitor-app",
    "productName": "Capacitor App",
    "files": [
      "assets/**",
      "build/**",
      "preloader.js",
      "plugins/**",
      "capacitor.config.json",
      "app/**"
    ],

Note another person had a cannot find module error because he was using www instead of app for the angular code directory: https://github.com/electron-userland/electron-builder/issues/303

user1689987
  • 1,002
  • 1
  • 8
  • 23
  • Yes, I tried it, unfortunately it doesn't work... – TOPKAT May 22 '22 at 19:01
  • i'll change my question into its obviously implied answer – user1689987 May 23 '22 at 01:46
  • 1
    @TOPKAT honestly maybe the best thing would be to get a friend with a mac to zip the directory created by the npm install of that package for you and put it in the node_modules directory or use a virtual box mac if that exists, or try it on a linux server and get the zip from there – user1689987 May 23 '22 at 01:53
  • 2
    ``` npm ERR! notsup Unsupported platform for iconv-corefoundation@1.1.7: wanted {"os":"darwin"} (current: {"os":"linux","arch":"x64"}) ``` – 404pio Jul 13 '22 at 11:21
  • 1
    @404pio `dmg-license` cannot be installed in Ubuntu or any variant of Linux. It can only be installed in [macOS (`darwin`)](https://en.wikipedia.org/wiki/Darwin_(operating_system)). – ADTC Mar 26 '23 at 06:57