You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Electron-Builder Version: tried on 24.13.3 & 24.6.4
Node Version: v20.12.2
Electron Version: tried with multiple versions
Electron Type (current, beta, nightly):
Target: Linux, MacOS, and Windows
This is a weird one.
The symptom I was having after updating my dependencies is that, the build worked fine, running the app graphically worked fine, but running it in a CLI mode failed with:
Error [ERR_REQUIRE_ESM]: require() of ES Module /tmp/.mount_SealdLpNtSLy/resources/app.asar/node_modules/wrap-ansi/node_modules/string-width/index.js from /tmp/.mount_SealdLpNtSLy/resources/app.asar/node_modules/wrap-ansi/index.js not supported.
Instead change the require of /tmp/.mount_SealdLpNtSLy/resources/app.asar/node_modules/wrap-ansi/node_modules/string-width/index.js in /tmp/.mount_SealdLpNtSLy/resources/app.asar/node_modules/wrap-ansi/index.js to a dynamic import() which is available in all CommonJS modules.
at c._load (node:electron/js2c/node_init:2:17025)
at Hook._require.Module.require (/tmp/.mount_SealdLpNtSLy/resources/app.asar/node_modules/require-in-the-middle/index.js:188:39)
at Object.<anonymous> (/tmp/.mount_SealdLpNtSLy/resources/app.asar/node_modules/wrap-ansi/index.js:2:21) {
code: 'ERR_REQUIRE_ESM'
}
This is surprising, as the version of string-width in my dependencies (well, my dependencies' dependencies) is 4.2.3 which is not ESM. See this result of npm ls string-width in my app directory:
However, when i tried unpacking the .asar built by electron-builder, and doing the npm ls in the unpacked directory, the results are different:
➜ asar_unpacked git:(master) ✗ npm ls string-width
npm ERR! code ELSPROBLEMS
npm ERR! extraneous: [email protected] /home/mehdi/Seald/zappa/releases_old/linux-unpacked/resources/asar_unpacked/node_modules/@isaacs/cliui/node_modules/string-width
npm ERR! invalid: [email protected] /home/mehdi/Seald/zappa/releases_old/linux-unpacked/resources/asar_unpacked/node_modules/wrap-ansi/node_modules/string-width
[email protected] /home/mehdi/Seald/zappa/releases_old/linux-unpacked/resources/asar_unpacked
├─┬ @isaacs/[email protected] extraneous
│ ├── [email protected] extraneous
│ └─┬ [email protected] invalid: "^8.1.0" from node_modules/@isaacs/cliui
│ └── [email protected] invalid: "^4.1.0" from node_modules/wrap-ansi
├─┬ wrap-ansi-cjs@npm:[email protected] extraneous
│ └── [email protected]
└─┬ [email protected]
├─┬ [email protected]
│ └── [email protected] deduped
└── [email protected] deduped
npm ERR! A complete log of this run can be found in:
npm ERR! /home/mehdi/.npm/_logs/2024-07-24T09_16_16_648Z-debug-0.log
At first, I did not understand at all where these dependencies were coming from. What it appears is that they are coming from the parent directory. I have no idea why electron-builder adds them to the build. So, in my case, if any of the dependencies in the project's directory (the root, not the app folder) has any newer version of string-width anywhere in its dependency tree, it is the one added in the in the root of my package in the asar, no idea why. And as it is a sub-dependency of glob@10, more and more packages depend on it indirectly.
In my case, to work around the problem, I had to rollback @rollup/plugin-commonjs to 25.0.8 as the 26 updates glob, plus I had to install [email protected] in my direct dev dependencies to avoid it being updated to semver-compatible 0.2.6 (which uses glob@10) when it is an indirect dependency (and it is a dependency of electron-builder itself through [email protected]).
I don't know if my explanations are very clear, sorry for being a bit rambly, this problem was very confusing.
Don't hesitate to ask if you have any more questions to help you debug, or if you need me to try out anything.
The text was updated successfully, but these errors were encountered:
Can you try nextv25.0.2 and see if that produces a different result? There were some node module copying changes/fixes that went in so I'm curious if that'll resolve your issue
24.13.3
&24.6.4
v20.12.2
This is a weird one.
The symptom I was having after updating my dependencies is that, the build worked fine, running the app graphically worked fine, but running it in a CLI mode failed with:
This is surprising, as the version of
string-width
in my dependencies (well, my dependencies' dependencies) is4.2.3
which is not ESM. See this result ofnpm ls string-width
in myapp
directory:However, when i tried unpacking the
.asar
built by electron-builder, and doing thenpm ls
in the unpacked directory, the results are different:At first, I did not understand at all where these dependencies were coming from. What it appears is that they are coming from the parent directory. I have no idea why
electron-builder
adds them to the build. So, in my case, if any of the dependencies in the project's directory (the root, not theapp
folder) has any newer version ofstring-width
anywhere in its dependency tree, it is the one added in the in the root of my package in the asar, no idea why. And as it is a sub-dependency ofglob@10
, more and more packages depend on it indirectly.In my case, to work around the problem, I had to rollback
@rollup/plugin-commonjs
to25.0.8
as the26
updates glob, plus I had to install[email protected]
in my direct dev dependencies to avoid it being updated to semver-compatible0.2.6
(which usesglob@10
) when it is an indirect dependency (and it is a dependency ofelectron-builder
itself through[email protected]
).I don't know if my explanations are very clear, sorry for being a bit rambly, this problem was very confusing.
Don't hesitate to ask if you have any more questions to help you debug, or if you need me to try out anything.
The text was updated successfully, but these errors were encountered: