electron-builder: Cannot find module '7zip-bin-mac' when packaging for mac
- Version: 19.27.0
- Target: mac
Getting this error message suddenly. Might have something to do with 7zip-bin-osx being renamed to 7zip-bin-mac?:
electron-builder 19.27.0
Using electron-builder.json configuration file
No native production dependencies
Packaging for darwin x64 using electron 1.7.6 to dist/mac
Downloading tmp-27704-1-SHASUMS256.txt-1.7.6
[============================================>] 100.0% of 2.93 kB (2.93 kB/s)
Error: Cannot find module '7zip-bin-mac'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (<project-path>/node_modules/7zip-bin/index.js:13:67)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at _load_zipBin (<project-path>/node_modules/electron-builder/out/packager/dirPackager.js:60:22)
error Command failed with exit code 255.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 4
- Comments: 20 (14 by maintainers)
Commits related to this issue
- fix: do not use optional dependencies because NPM is broken by design Close #2013 — committed to develar/electron-builder by develar 6 years ago
- fix: do not use optional dependencies because NPM is broken by design Close #2013 — committed to develar/electron-builder by develar 6 years ago
NEVER use
npm. Especially, NEVER use package–lock.jsonnpmhas a lot of bugs and each new version add new ones. Do not waste your time — just use reliable, fast, stable yarn.If you use NPM — do not use it. Please remove node_modules and install using yarn.
May be it helps to somebody. In my case when I had this error, optional package installation was disabled. To check it run
npm config listand noticeoptionalsetting. If itfalsetry to set it bynpm config set optional trueand reinstall packages bynpm install. And @develar don’t push people to change something because you or your soft don’t like this “something”. Usually people can’t just change it when the product in production or the team accustomed to present choice. Any change cost money. And by the way after all each soft has bugs. Yarn isn’t an exception.I used to prefer Yarn but recent versions of npm work just fine to be honest. I think the issue is that electron-builder has been developed with yarn only and relies on its peculiarities. Maybe the doc should be updated to reflect this - instead of “Yarn is strongly recommended instead of npm” it should be “Yarn is required. It will NOT work with npm.”
Just ran into this.
rm -rf ./node_modules && rm yarn.lock && yarn installfixed it.electron-builder 20.14.4+ doesn’t use optional dependencies. Enjoy.
We had a similar problem. In our case, it seems to occur because “packages-lock.json” is generated by “npm i” (npm v5.3) on Windows, committed to git, and then used to build on Mac (on Travis).
It seems that packages.lock only mentions that “electron-builder” requires “7zip-bin” which then requires"7zip-bin-win" and does not mention “7zip-bin-mac”.
@develar How do you recommend we deal with this (since you are author of 7zip-bin where both 7zip-bin-win and 7zip-bin-mac are listed as optional dependencies)? Or is this something that is solved by using yarn?
Please install as optional dependency in your project as workaround: