question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to load module that isn't specified in Electron app's package.json

See original GitHub issue

I’m trying to package an electron app which resides in electron-app/ folder in my project folder. The modules are installed in ../node_modules folder.

I have a module that is required in the preload script(electron-app/preload.js) and attached to the window object. After packaging this app, electron throws the said error with module not found, but if I install the module in the electron-app folder, everything works fine.

I’ve tried to push the ../node_modules to module.paths but to no avail.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
maleptcommented, Mar 2, 2018

How would it know about those folders? You’ve specified that the app resides in electron-app, not its parent directory. Electron Packager doesn’t copy anything in the app’s parent directory.

1reaction
maleptcommented, Feb 28, 2018

In order to debug your problem further, we need a minimal testcase to reproduce your problem. Using the electron-quick-start repository as a base, could you please create a minimal Electron app that illustrates the issue you described, and post a link to it here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Electron-packager: cannot find module - Stack Overflow
For me, I had to specify "main": "./dist/main.js" in package.json because it was trying to find index.js which is probably the default value....
Read more >
package-lock.json - npm Docs
Description. package-lock.json is automatically generated for any operations where npm modifies either the node_modules tree, or package.json .
Read more >
Creating an Electron application from scratch
An Electron application is an npm project with the electron package as a dependency. Our first steps will be creating the npm project...
Read more >
Node Modules at War: Why CommonJS and ES ... - Code Red
Put the ESM wrapper in an esm subdirectory, alongside a one-line package.json file that says {"type": "module"} . (You could rename your wrapper ......
Read more >
module not found error can't resolve 'fs' in electron - You.com
The error is because angular-CLI does not support modules in Nodejs like "fs" and "path". Add the following to the root of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found