Electron-packager: cannot find module

For me the problem was that the module dependencies were listed in "devDependencies" in package.json

Moving them to "dependencies" and running npm install again solved the problem.


Two things you can try:

  • Make sure every node modules that you need to run on production build added into dependencies in package.json. E.g: npm install <module_name> --save
  • How does it work when --asar=false (More info at https://github.com/electron-userland/electron-packager)

So i had this same problem. Mine got solved when i cd in to my project folder and did

npm i -D electron@latest

Sometimes adding in package.json and npm install would not have installed it properly. Please lemme know if it worked for you.

Tags:

Electron