electron-userland / electron-json-storage

:package: Easily write and read user settings in Electron apps
1.43k stars 79 forks source link

Issues finding modules from EJS using electron packager (Monorepo setup) #171

Closed iamterryclark closed 2 years ago

iamterryclark commented 2 years ago

I am trying to package my application using electron-packager and have required the EJS module into my electron main.js file.

// main.js
const storage = require('electron-json-storage');

// Do other electron stuff and store some data

I added EJS in my dependencies but am not able to run the packaged application as it complains about not finding lodash ... and I presume all of the other dependencies located in EJS package.json

I added EJS as a dependency of my application so that my main.js would find the module. Otherwise electron would prune this from the resources folder when packaging.

 "dependencies": {
    "electron-json-storage": "^4.5.0"
  },

Anyone else having this issue?

jviotti commented 2 years ago

Hey @iamterryclark ,

Are you sure this is related to electron-json-storage? Does the issue disappear if you uninstall electron-json-storage? If not, it might be a problem to report to electron-packager instead.

iamterryclark commented 2 years ago

Thanks for getting back.

This is the only external module I am using on the main process side of the code. Other than with child and path modules along with require('electron-devtools-installer') which only gets required in dev mode. I have packaged the app many times before adding this module with no issues.

I will keep looking into packager, in case I have --ignored something crucial.

iamterryclark commented 2 years ago

My apologies,

I am also developing this app inside a monorepo, which hoists dependencies up. more information on this I found here https://github.com/lerna/lerna/blob/main/doc/hoist.md. No solution as yet, i need to stop the hoisting on this modules dependencies and their sub dependences.

must be an thing with requiring modules. I guess a work around would be for me to use this on the renderer process code instead,

My current work around is to add all EJS dependencies as my own in my package.json


"workspaces": {
    "nohoist": [
      "async",
      "lockfile",
      "lodash",
      "mkdirp",
      "rimraf",
      "write-file-atomic",
      "graceful-fs",
      "imurmurhash",
      "signal-exit"
    ]
  },
  "dependencies": {
    "async": "^3.2.3",
    "electron-json-storage": "^4.5.0",
    "graceful-fs": "^4.2.9",
    "imurmurhash": "^0.1.4",
    "lockfile": "^1.0.4",
    "lodash": "^4.17.21",
    "mkdirp": "^1.0.4",
    "rimraf": "^3.0.2",
    "signal-exit": "^3.0.6",
    "write-file-atomic": "^4.0.0"
 }

I think this is more fundamental to how workspaces work, rather than an issue with this library
Closing Issue