Open icabetong opened 2 years ago
I also ran into this issue after upgrading from 22.11.7 to 22.14.5 today. The stack trace was as follows:
[electron:build] > lightsaber-systems-designer@0.6.0-beta.1 electron:build /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer
[electron:build] > electron-builder build --publish=always
[electron:build]
[electron:build] • electron-builder version=22.14.5 os=19.6.0
[electron:build] • loaded configuration file=/opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/electron-builder.json
[electron:build] ⨯ Cannot find module 'cli-truncate'
[electron:build] Require stack:
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/iconv-corefoundation/lib/errors.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/iconv-corefoundation/lib/native.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/iconv-corefoundation/lib/index.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/dmg-license/lib/Labels.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/dmg-license/lib/assembleLicenses.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/dmg-license/lib/index.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/dmg-builder/out/dmgLicense.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/dmg-builder/out/dmg.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/dmg-builder/out/dmgUtil.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/app-builder-lib/out/macPackager.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/app-builder-lib/out/packager.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/app-builder-lib/out/index.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/electron-builder/out/builder.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/electron-builder/out/cli/cli.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/electron-builder/cli.js failedTask=build stackTrace=Error: Cannot find module 'cli-truncate'
[electron:build] Require stack:
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/iconv-corefoundation/lib/errors.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/iconv-corefoundation/lib/native.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/iconv-corefoundation/lib/index.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/dmg-license/lib/Labels.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/dmg-license/lib/assembleLicenses.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/dmg-license/lib/index.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/dmg-builder/out/dmgLicense.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/dmg-builder/out/dmg.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/dmg-builder/out/dmgUtil.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/app-builder-lib/out/macPackager.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/app-builder-lib/out/packager.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/app-builder-lib/out/index.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/electron-builder/out/builder.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/electron-builder/out/cli/cli.js
[electron:build] - /opt/builds/nr7ZdCYE/0/wunker-bunker/lightsaber-systems-designer/node_modules/electron-builder/cli.js
[electron:build] at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
[electron:build] at Function.Module._load (internal/modules/cjs/loader.js:746:27)
[electron:build] at Module.require (internal/modules/cjs/loader.js:974:19)
[electron:build] at require (internal/modules/cjs/helpers.js:93:18)
[electron:build] at Object.
Going to version 22.13.1 fixed this issue for me.
Same issue running on github actions.
Building the Electron app… • electron-builder version=22.13.1 os=19.6.0 • artifacts will be published if draft release exists reason=CI detected • loaded configuration file=package.json ("build" field) • loaded parent configuration preset=react-cra • description is missed in the package.json appPackageFile=/Users/runner/work/por/por/package.json • author is missed in the package.json appPackageFile=/Users/runner/work/por/por/package.json ⨯ Cannot find module 'cli-truncate'
Same error below versions. • electron-builder version=22.13.1 os=20.6.0 • electron-builder version=22.14.5 os=20.6.0
I managed to avoid this error installing cli-truncate
on my project...
"devDependencies": {
"cli-truncate": "2.1.0",
"electron": "16.0.6",
"electron-builder": "22.14.5",
"electron-notarize": "1.1.1"
}
Would someone be willing to put together a sample project I can test this with? My project is unable to reproduce locally. Also happy to review a PR for fixing this. Setting up a local dev env is fairly simple too https://github.com/electron-userland/electron-builder/blob/master/CONTRIBUTING.md#to-setup-a-local-dev-environment
npm install cli-truncate -D
then npm uninstall cli-truncate
worked for me.
this will add cli-truncate with optional: true
to package-lock.json
I am also blocked by this, I tried both of these suggestions:
cli-truncate
package. Then I got an error about the package.json type field, commonjs/module. Setting the value to either did not work because then it broke other stuff with the same error message: require() of ES modules is not supported.
A whole can of worms on this thread where the creator of cli-truncate
goes into detail about ESM/CJS and there is even a section for electron https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#how-can-i-import-esm-in-electron . Looks like you have to install the prev major version that was CJS first (same problem with the chalk repo btw).
Only after I went through that thread did I realize @rogeriorc pinned his version to 2.1.0, which is the prev version I am speaking about. That worked.
Try the following solutions, it worked for me:
Solution 1:
node_modules
directory and package-lock.json
filenpm install
cli-truncate
exists in package.lock.json
file, if cli-truncate
exists, then your dependencies are fixedSolution 2:
npm install cli-truncate@2.1.0 -D
npm uninstall cli-truncate
cli-truncate
exists in package.lock.json
file, if cli-truncate
exists, then your dependencies are fixedIs 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.
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.
I had this issue myself today as well.
Electron: 13.6.6 Node: 14.20.0
Get same issue on github action. runs-on: macos-latest
Here is my version.
"electron": "^15.3.1",
"electron-builder": "^23.3.3",
Packaging for macOS with DMG target throws an
node module failed: cannot find module 'cli-truncate'
. However, I tried to target as PKG and it successfully worked.