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

"Error: Cannot find module 'jsonfile/utils'" in linux appimage build #8503

Closed
cmdcolin opened this issue Sep 19, 2024 · 17 comments · Fixed by develar/app-builder#143
Closed

Comments

@cmdcolin
Copy link

cmdcolin commented Sep 19, 2024

  • Electron-Builder Version:

"[email protected]"

  • Node Version:
    20.17.0/x64 on github actions
  • Target:
    AppImage

Latest build of AppImage fails to start with error message:

 ./jbrowse-desktop-v2.15.3-linux.AppImage
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Cannot find module 'jsonfile/utils'
Require stack:
- /tmp/.mount_jbrowsjehAMT/resources/app.asar/node_modules/electron-updater/node_modules/fs-extra/lib/json/output-json.js
- /tmp/.mount_jbrowsjehAMT/resources/app.asar/node_modules/electron-updater/node_modules/fs-extra/lib/json/index.js
- /tmp/.mount_jbrowsjehAMT/resources/app.asar/node_modules/electron-updater/node_modules/fs-extra/lib/index.js
- /tmp/.mount_jbrowsjehAMT/resources/app.asar/node_modules/electron-updater/out/main.js
- /tmp/.mount_jbrowsjehAMT/resources/app.asar/build/electron.js
-
    at Module._resolveFilename (node:internal/modules/cjs/loader:1232:15)
    at s._resolveFilename (node:electron/js2c/browser_init:2:124039)
    at Module._load (node:internal/modules/cjs/loader:1058:27)
    at c._load (node:electron/js2c/node_init:2:17025)
    at Module.require (node:internal/modules/cjs/loader:1318:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/tmp/.mount_jbrowsjehAMT/resources/app.asar/node_modules/electron-updater/node_modules/fs-extra/lib/json/output-json.js:3:23)
    at Module._compile (node:internal/modules/cjs/loader:1484:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1564:10)
    at Module.load (node:internal/modules/cjs/loader:1295:32)

if i unzip the app.asar file, i can see that there is a app.asar/node_modules/jsonfile but that is v4, while the fs-extra there wants v6

here are some screenshots, see filename paths pointing the the node_modules directory that i unzipped from the app.asar file with "npx @electron/asar extract app.asar outdir"

image

image

I normally use "yarn" (v1) to install my node_modules in my normal monorepo, but am unsure how the node_modules directory is constructed for this project. I haven't yet traced the exact root cause, but seems something with the node_modules directory format/construction in the app.asar

i update versions of stuff a lot so dont know exactly the cause. this is the entire diff of the yarn.lock between a version that works (did not give the above error) and a version that gave the error. i didn't see anything that really stood out (no fs-extra changes, no jsonfile changes, no electron-builder changes, no electron-updater changes

if i had one question, it would probably be how the node_modules in the app.asar is created?

this is the full diff between a working version of our app and the failing https://github.com/GMOD/jbrowse-components/compare/v2.15.1..v2.15.3/ (v2.15.2 was skipped)

@cmdcolin
Copy link
Author

note that the app works on mac. im not currently building any other linux targets

@cmdcolin
Copy link
Author

weirdly, this AppImage instance was built via a github action, but if i build it locally, it seemed to work (??)

@cmdcolin
Copy link
Author

a similar bug here suggests deleting the lockfile and re-installing storybookjs/storybook#22682 but i am not sure if that would apply in my case because the local build i mention above has the same yarn.lock as the github action

@mmaietta
Copy link
Collaborator

@cmdcolin was this working previoiusly on 24.13.3? Just looking to triage if this was recently introduced.

@cmdcolin
Copy link
Author

the diff at https://github.com/GMOD/jbrowse-components/compare/v2.15.1..v2.15.3/ actually didnt have anything related to electron builder, electron-updater, fs-extra, or jsonfile (all the culprits from thw stack trace) so it is wuite odd. we previously used electron build3r 24, had a successful release with v25 in with our products v2.15.1, but had this happem in latest v2.15.3

If its too weird a bug could certainly close. thw fact i built the same thing locally instead of via github action akd it worked suggests some nondeterminism or other weird thing (my local is otherwise quite similar to the github action on os, emvironment, etc)

@beyondkmp
Copy link
Collaborator

@cmdcolin Could you help to try v25.1.3 ?

@cmdcolin
Copy link
Author

I can give it a shot, might be a little bit till i am able to get around to it! am I correct in thinking that the 'conflictDependency' mentioned there could be relevant to this?

@cmdcolin
Copy link
Author

found this happened in the windows build exe installer also, i haven't had a chance to update to the electron-builder@next/25.1.x branch yet though

@beyondkmp
Copy link
Collaborator

@cmdcolin deploying release v25.1.6 now. Please update when you have a chance

@s100
Copy link

s100 commented Sep 30, 2024

Seeing a similar issue here while trying to upgrade from electron-builder@24 to 25.0.5. The electron-build process completes successfully but attempting to launch the built Electron app gives a popup saying:

[Window Title]
Error

[Main Instruction]
A JavaScript error occurred in the main process

[Content]
Uncaught Exception:
Error: Cannot find module 'string-width'
Require stack:
- C:\...\app.asar\node_modules\cliui\build\index.cjs
- C:\...\app.asar\node_modules\yargs\build\index.cjs
- C:\...\app.asar\node_modules\yargs\index.cjs
- C:\...\app.asar\node_modules\nconf\lib\nconf\stores\argv.js
- C:\...\app.asar\node_modules\nconf\lib\nconf.js
- ...
    at Module._resolveFilename (node:internal/modules/cjs/loader:1232:15)
    at s._resolveFilename (node:electron/js2c/browser_init:2:124038)
    at Module._load (node:internal/modules/cjs/loader:1058:27)
    at c._load (node:electron/js2c/node_init:2:17025)
    at Module.require (node:internal/modules/cjs/loader:1318:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (C:\...\app.asar\node_modules\cliui\build\index.cjs:291:21)
    at Module._compile (node:internal/modules/cjs/loader:1484:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1564:10)
    at Module.load (node:internal/modules/cjs/loader:1295:32)

[OK]

string-width is indeed a production dependency of cliui so I don't see why it would not be making its way into the ASAR.

This is with no changes to our config. If there are breaking/API changes for electron-builder@25 I wasn't able to find any.

@beyondkmp
Copy link
Collaborator

beyondkmp commented Sep 30, 2024

@s100 v25.1.6 has fixed this bug. Please try it.

@osztenkurden
Copy link

osztenkurden commented Oct 14, 2024

Im having similiar issue (but with archiver-utils package, dependency of exceljs), with basically all 25+ version, 24.2.0 works properly though

@KillerCodeMonkey
Copy link

KillerCodeMonkey commented Oct 14, 2024

@osztenkurden the same with archiver-utils. we upgraded electron builder from 25.0.5 to 25.1.7 and electron 32.x

We are using archiver package in your to create zips and never had a problem.

i checked the package-lock and it seems only some squirrel package of eletron-builder depend on archiver-util. i do not know why it is then required for linux/macos builds in our app.

@beyondkmp
Copy link
Collaborator

beyondkmp commented Oct 15, 2024

@osztenkurden @KillerCodeMonkey
I cannot reproduce the issue you mentioned with the archiver-utils. Could you please provide a minimal reproducible demo?

{
  "name": "TestApp",
  "productName": "Test App ßW",
  "description": "My Electron application description",
  "keywords": [],
  "main": "./main.js",
  "version": "1.0.0",
  "author": "beyondkmp",
  "scripts": {
    "start": "electron .",
    "dist": "electron-builder"
  },
  "license": "MIT",
  "build": {
    "appId": "electron-blog-example",
    "win": {
      "target": "nsis"
    }
  },
  "devDependencies": {
    "electron": "32.1.0",
    "electron-builder": "25.1.7"
  },
  "dependencies": {
     "exceljs":"4.4.0",
    "archiver-utils":"5.0.2",
    "archiver":"7.0.1"
  }
}

@KillerCodeMonkey
Copy link

KillerCodeMonkey commented Oct 15, 2024

@beyondkmp please do not install archiver-utils as dependency

I never had it in my package.json and needed it there.
It should be automatically installed as dependency of some squirrel packages.
But the error occurs on macos (dmg) and linux (AppImage) as well.

So it can not be that all of a sudden i have to install prod dependencies in my project, that i do not use directly.

PS: sure when i add the dependency to my package.json it is working... but i do not want to have dependencies there that i do not really use and nobody knows why it is there..

@beyondkmp
Copy link
Collaborator

@KillerCodeMonkey Thanks. It will be fixed in develar/app-builder#143

@KillerCodeMonkey
Copy link

noice! thank you for the fast response.

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

Successfully merging a pull request may close this issue.

6 participants