Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'dmg-license' #6520

Closed
pranavwani opened this issue Dec 29, 2021 · 20 comments
Closed

Cannot find module 'dmg-license' #6520

pranavwani opened this issue Dec 29, 2021 · 20 comments

Comments

@pranavwani
Copy link

pranavwani commented Dec 29, 2021

  • Electron-Builder Version: 22.14.5
  • Node Version: v14.17.3
  • Electron Version: v12.0.0
  • Electron Type (current, beta, nightly): current
  • Electron Update Version: v4.6.1
  • Target: dmg

Stack

⨯ Cannot find module 'dmg-license'
Require stack:
- /usr/local/share/.config/yarn/global/node_modules/dmg-builder/out/dmgLicense.js
- /usr/local/share/.config/yarn/global/node_modules/dmg-builder/out/dmg.js
- /usr/local/share/.config/yarn/global/node_modules/dmg-builder/out/dmgUtil.js
- /usr/local/share/.config/yarn/global/node_modules/app-builder-lib/out/macPackager.js
- /usr/local/share/.config/yarn/global/node_modules/app-builder-lib/out/packager.js
- /usr/local/share/.config/yarn/global/node_modules/app-builder-lib/out/index.js
- /usr/local/share/.config/yarn/global/node_modules/electron-builder/out/builder.js
- /usr/local/share/.config/yarn/global/node_modules/electron-builder/out/cli/cli.js
- /usr/local/share/.config/yarn/global/node_modules/electron-builder/cli.js  failedTask=build stackTrace=Error: Cannot find module 'dmg-license'
@robertpatrick
Copy link
Contributor

@pranavwani dmg-builder, a component of electron-builder, declares an optional dependency on dmg-license so yarn add electron-builder should install it, as shown below.

% yarn add electron-builder --dev
yarn add v1.22.17
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
success Saved 175 new dependencies.
info Direct dependencies
└─ [email protected]
info All dependencies
├─ @develar/[email protected]
├─ @electron/[email protected]
├─ @malept/[email protected]
├─ @malept/[email protected]
├─ @sindresorhus/[email protected]
├─ @szmarczak/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
✨  Done in 17.33s.
%  ls -al node_modules/dmg-license              
total 88
drwxr-xr-x    9 rpatrick  staff    288 Dec 31 17:25 .
drwxr-xr-x  199 rpatrick  staff   6368 Dec 31 17:26 ..
-rw-r--r--    1 rpatrick  staff   1070 Dec 31 17:25 LICENSE
-rw-r--r--    1 rpatrick  staff   1995 Dec 31 17:25 README.md
drwxr-xr-x    3 rpatrick  staff     96 Dec 31 17:26 bin
-rw-r--r--    1 rpatrick  staff  21188 Dec 31 17:25 language-info.json
drwxr-xr-x   23 rpatrick  staff    736 Dec 31 17:26 lib
-rw-r--r--    1 rpatrick  staff   1887 Dec 31 17:25 package.json
-rw-r--r--    1 rpatrick  staff   6512 Dec 31 17:25 schema.json
% 

@pranavwani
Copy link
Author

Hi, @robertpatrick exactly. May be I'm wrong please checkout the source code may be something wrong where in current release imported 'dmg-license' into the same package in 'dmgLicense.ts' which was removed in v29

v22

v29

@rpatrick00
Copy link

@pranavwani But it is still there in master…

import { dmgLicenseFromJSON } from "dmg-license"

@pranavwani
Copy link
Author

pranavwani commented Jan 1, 2022

Actually I thought this is the problem that module imported in its own source code 'dmg-license' into in its source code may be which will be fixed in upcoming release v29

I've test with

Electron-Builder Version: 22.14.5
Node Version: v14.17.3
Electron Version: v12.0.0
Electron Type (current, beta, nightly): current
Electron Update Version: v4.6.1

Still need to figure out

@pranavwani
Copy link
Author

@rpatrick00 any other possible solution?

@robertpatrick
Copy link
Contributor

@pranavwani While I'm not using yarn, my current project (https://github.com/oracle/weblogic-toolkit-ui) is using electron-builder and we are not seeing this problem. There is a smaller example at https://github.com/robertpatrick/electron-updater-example (a fork from another project) that you could try out to see if it works for you.

@pranavwani
Copy link
Author

Thanks for sharing @rpatrick00. I'll check it out

And happy new year 🎉

@pranavwani
Copy link
Author

Temporary fix by set dependency

Electron updater: v4.3.9
Electron builder: v22.10.5

@robertpatrick
Copy link
Contributor

@pranavwani The other option is to move to the next version of electron-builder. I am currently using the next version of both electron-builder and electron-updates to pick up fixes that I need.

@pranavwani
Copy link
Author

Yeah this should work. Just need to check thanks

@lyswhut
Copy link

lyswhut commented Jan 13, 2022

I got a similar error:

> cross-env electron-builder -m=dmg -p never

  • electron-builder  version=22.14.5 os=20.6.0
  • loaded configuration  file=package.json ("build" field)
  ⨯ Cannot find module 'cli-truncate'
Require stack:
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/iconv-corefoundation/lib/errors.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/iconv-corefoundation/lib/native.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/iconv-corefoundation/lib/index.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/dmg-license/lib/Labels.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/dmg-license/lib/assembleLicenses.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/dmg-license/lib/index.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/dmg-builder/out/dmgLicense.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/dmg-builder/out/dmg.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/dmg-builder/out/dmgUtil.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/app-builder-lib/out/macPackager.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/app-builder-lib/out/packager.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/app-builder-lib/out/index.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/electron-builder/out/builder.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/electron-builder/out/cli/cli.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/electron-builder/cli.js  failedTask=build stackTrace=Error: Cannot find module 'cli-truncate'
Require stack:
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/iconv-corefoundation/lib/errors.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/iconv-corefoundation/lib/native.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/iconv-corefoundation/lib/index.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/dmg-license/lib/Labels.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/dmg-license/lib/assembleLicenses.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/dmg-license/lib/index.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/dmg-builder/out/dmgLicense.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/dmg-builder/out/dmg.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/dmg-builder/out/dmgUtil.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/app-builder-lib/out/macPackager.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/app-builder-lib/out/packager.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/app-builder-lib/out/index.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/electron-builder/out/builder.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/electron-builder/out/cli/cli.js
- /Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/electron-builder/cli.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (/Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/iconv-corefoundation/lib/errors.js:4:21)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (/Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/iconv-corefoundation/lib/native.js:4:16)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (/Users/runner/work/lx-music-desktop/lx-music-desktop/node_modules/iconv-corefoundation/lib/index.js:6:18)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] pack:mac:dmg: `cross-env electron-builder -m=dmg -p never`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] pack:mac:dmg script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

@pranavwani
Copy link
Author

@lyswhut try to check following solutions

@lyswhut
Copy link

lyswhut commented Feb 26, 2022

I got it working again: #6471 (comment)

@stale
Copy link

stale bot commented Apr 28, 2022

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the backlog label Apr 28, 2022
@robertpatrick
Copy link
Contributor

@mmaietta I think this is resolved so you can close it

@stale stale bot removed the backlog label Apr 28, 2022
noriyotcp added a commit to noriyotcp/fragmemo that referenced this issue Jun 26, 2022
Cannot find module 'dmg-license' when building Electron app
electron-userland/electron-builder#6520
@catdad
Copy link
Contributor

catdad commented Feb 19, 2023

For anyone who lands here like me. This issue is not really resolved, and it is not really so much an issue with this module. But it is an issue nonetheless.

This happens to me all the time due to the way I update dependencies. Usually, I delete my package-lock.json and node modules, and then I reinstall. This recreates the package-lock.json file with all the latest modules, respecting semver. If tests pass, there's a good chance everything is still fine. Problem solves, right?

Well, this is where the issue described here occurs. I develop on Windows (sometimes even Linux), but never a Mac. This project, however, has optional dependencies that install only on a Mac. Well... guess what happens when I create my package-lock.json file on Windows? Those optional dependencies are missing. Or... at least the dependencies of those optional dependencies are missing. Later, when the project is installed on a Mac (like in CI), it fails to install those missing dependencies, and building fails.

Since I forget every time and have to search for it, here is how I fix it (without a Mac... if you have a Mac, just generate a package-lock.json file there):

  • Find the parent of the missing module.
  • Install that parent with --force... in the case of cli-truncate, I run npm i -D dmg-license -f
  • This will add dmg-license to your package.json file, where you don't want it... delete it
  • Run npm i again

When looking at your package-lock.json file, now you should see that cli-truncate has been added to it. Commit that change.

As for who actually needs to fix what: I have no clue 🤷‍♀️. This is probably an npm bug?

@robertpatrick
Copy link
Contributor

Seems like a bad interaction between package-lock.json and optional packages to me…

@theryansmee
Copy link

For anyone who lands here like me. This issue is not really resolved, and it is not really so much an issue with this module. But it is an issue nonetheless.

This happens to me all the time due to the way I update dependencies. Usually, I delete my package-lock.json and node modules, and then I reinstall. This recreates the package-lock.json file with all the latest modules, respecting semver. If tests pass, there's a good chance everything is still fine. Problem solves, right?

Well, this is where the issue described here occurs. I develop on Windows (sometimes even Linux), but never a Mac. This project, however, has optional dependencies that install only on a Mac. Well... guess what happens when I create my package-lock.json file on Windows? Those optional dependencies are missing. Or... at least the dependencies of those optional dependencies are missing. Later, when the project is installed on a Mac (like in CI), it fails to install those missing dependencies, and building fails.

Since I forget every time and have to search for it, here is how I fix it (without a Mac... if you have a Mac, just generate a package-lock.json file there):

  • Find the parent of the missing module.
  • Install that parent with --force... in the case of cli-truncate, I run npm i -D dmg-license -f
  • This will add dmg-license to your package.json file, where you don't want it... delete it
  • Run npm i again

When looking at your package-lock.json file, now you should see that cli-truncate has been added to it. Commit that change.

As for who actually needs to fix what: I have no clue 🤷‍♀️. This is probably an npm bug?

This comment is absolutely spot on. Thank you for shedding some light and giving a solution 🔥

@gRoussac
Copy link

Hi, It is reproduced on Linux with electron-builder --mac

    "electron": "^26.1.0",
    "electron-builder": "^24.6.3",
    "electron-updater": "^6.1.1"

with

node v20.5.1
npm 9.8.1

adding

    "dmg-license": "^1.0.11",

leads to another error

npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"darwin"} (current: {"os":"linux"})
npm ERR! notsup Valid os:  darwin
npm ERR! notsup Actual os: linux

Changing to linux in package.json leads to

electron/node_modules/iconv-corefoundation/lib/native.node: invalid ELF header

electron-builder --win --linux seems to execute to the end however

not sure if it is me trying to emit an dmg on Linux or a bug in last versions.

@undergroundwires
Copy link

I had the same issue with 24.6.4, I tried different solutions and the cleanest solution I found which works cross operating systems consistently and represents the intention explicitly in code was:

npm install "dmg-license" --save-optional

This adds following lines to package.json:

  "optionalDependencies": {
    "dmg-license": "^1.0.11"
  },

undergroundwires added a commit to undergroundwires/privacy.sexy that referenced this issue Nov 1, 2023
- Migrate from "Vue 2.X" to "Vue 3.X"
- Migrate from "Vue Test Utils v1" to "Vue Test Utils v2"

Changes in detail:

- Change `inserted` to `mounted`.
- Change `::v-deep` to `:deep`.
- Change to Vue 3.0 `v-modal` syntax.
- Remove old Vue 2.0 transition name, keep the ones for Vue 3.0.
- Use new global mounting API `createApp`.
- Change `destroy` to `unmount`.
- Bootstrapping:
  - Move `provide`s for global dependencies to a bootsrapper from
    `App.vue`.
  - Remove `productionTip` setting (not in Vue 3).
  - Change `IVueBootstrapper` for simplicity and Vue 3 compatible API.
  - Add missing tests.
- Remove `.text` access on `VNode` as it's now internal API of Vue.
- Import `CSSProperties` from `vue` instead of `jsx` package.
- Shims:
  - Remove unused `shims-tsx.d.ts`.
  - Remove `shims-vue.d.ts` that's missing in quickstart template.
- Unit tests:
  - Remove old typing workaround for mounting components.
  - Rename `propsData` to `props`.
  - Remove unneeded `any` cast workarounds.
  - Move stubs and `provide`s under `global` object.

Other changes:

- Add `dmg-license` dependency explicitly due to failing electron builds
  on macOS (electron-userland/electron-builder#6520,
  electron-userland/electron-builder#6489). This was a side-effect of
  updating dependencies for this commit.
LarrMarburger added a commit to LarrMarburger/privacy.sexy that referenced this issue Nov 16, 2023
- Migrate from "Vue 2.X" to "Vue 3.X"
- Migrate from "Vue Test Utils v1" to "Vue Test Utils v2"

Changes in detail:

- Change `inserted` to `mounted`.
- Change `::v-deep` to `:deep`.
- Change to Vue 3.0 `v-modal` syntax.
- Remove old Vue 2.0 transition name, keep the ones for Vue 3.0.
- Use new global mounting API `createApp`.
- Change `destroy` to `unmount`.
- Bootstrapping:
  - Move `provide`s for global dependencies to a bootsrapper from
    `App.vue`.
  - Remove `productionTip` setting (not in Vue 3).
  - Change `IVueBootstrapper` for simplicity and Vue 3 compatible API.
  - Add missing tests.
- Remove `.text` access on `VNode` as it's now internal API of Vue.
- Import `CSSProperties` from `vue` instead of `jsx` package.
- Shims:
  - Remove unused `shims-tsx.d.ts`.
  - Remove `shims-vue.d.ts` that's missing in quickstart template.
- Unit tests:
  - Remove old typing workaround for mounting components.
  - Rename `propsData` to `props`.
  - Remove unneeded `any` cast workarounds.
  - Move stubs and `provide`s under `global` object.

Other changes:

- Add `dmg-license` dependency explicitly due to failing electron builds
  on macOS (electron-userland/electron-builder#6520,
  electron-userland/electron-builder#6489). This was a side-effect of
  updating dependencies for this commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants