简体   繁体   English

电子生成器错误:找不到模块“dmg-license”

[英]electron-builder error: Cannot find module 'dmg-license'

I am looking for a simple way to build an electron app for macOS, from a linux machine.我正在寻找一种简单的方法来从 linux 机器构建适用于 macOS 的 electron 应用程序。

Unfortunately, the electron-builder -m command doesn't work, here is the full output of the command:不幸的是, electron-builder -m命令不起作用,这里是命令的完整 output:

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...我已尝试安装依赖项,但它只能安装在 macOS 上...

I have also tried to install different versions, including 20.37.* , 22.11.7 , @latest ( 22.14.13 ) and @next我还尝试安装不同的版本,包括20.37.*22.11.7@latest ( 22.14.13 ) 和@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)?有没有其他方法可以为 macOS 构建应用程序(我正在使用的程序是出于私人目的,所以如果需要额外的用户步骤来安装也没关系)?

Or any way to fix this dependency issue?或者有什么方法可以解决这个依赖问题?

Try:尝试:

npm i dmg-license

Perhaps this would be an alternative way to build.也许这将是另一种构建方式。 https://www.electronforge.io/ 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.我遇到了类似的错误,但我的问题是我创建了子目录,默认 package.json 仅包含构建中的顶级目录。 The solution was to change in my electron package.json解决方案是更改我的 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注意另一个人有一个cannot find module错误,因为他使用 www 而不是应用程序来获取 angular 代码目录: https://github.com/electron-userland/electron-builder/issues/303

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM