[Solved ]Build successful but Electron app is missing at least a JS module

Hi.

I am building an Electron app and the build process is successful: https://flathub.org/builds/#/builders/32/builds/34661

To generate the “generated-sources.json” I use the flatpak-node-generator.py script (https://github.com/flatpak/flatpak-builder-tools/tree/master/node) like this “flatpak-node-generator.py npm --xdg-layout package-lock.json”

After installing the test build and running it, the app crashes and throws this error:

A JavaScript error occurred in the main process
Uncaught Exception:
Error: Cannot find module './dist/cjs/i18next.js'
Require stack:
- /app/sleek/resources/app.asar/node_modules/i18next/index.js
- /app/sleek/resources/app.asar/src/configs/i18next.config.js
- /app/sleek/resources/app.asar/src/main.js
- 
    at Module._resolveFilename (internal/modules/cjs/loader.js:972:15)
    at Function.n._resolveFilename (electron/js2c/browser_init.js:249:921)
    at Module._load (internal/modules/cjs/loader.js:848:27)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12694)
    at Module.require (internal/modules/cjs/loader.js:1032:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/app/sleek/resources/app.asar/node_modules/i18next/index.js:2:12)
    at Module._compile (internal/modules/cjs/loader.js:1152:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1173:10)
    at Module.load (internal/modules/cjs/loader.js:992:32)

So for whatever reason at least the inext18 package is not being downloaded or placed into the right place even though it is stated in the generated-sources.json file.

I don’t think the cause is the app itself. I can easily “npm start” the app locally without any errors and the Snapcraft build runs perfectly well. It only crashes after the Flatpak building process.

Does anybody has a little bit of experience with Electron apps and Flatpak and can help me figuring out why this happens?

This problem has been solved.

I made a mistake in package.json by excluding my output directory for the binaries from the build process. The output directory’s name is “dist” and so it exluded not only the output directory but also the “dist” directory in the i18next module.