Uncaught Exception: Cannot find module ../package.json
See original GitHub issueNOTE: before openning an issue, please consult previous issues (both open and closed).
What is the problem
The module raises an exception:
Uncaught Exception:
Error: Cannot find module '/home/myuser/projects/myproject/main/package.json'
How to reproduce
Include require("electron-reload")(app.getAppPath() + "../renderer") in the entrypoint of the program.
Additional information
This happens with Electron 5.0.6
Apparently, getAppPath() points to the entry point of the program, which in this case is /home/myuser/projects/myproject/main/main.js. The problem is that package.json is in /home/myuser/projects/myproject/ not in /home/myuser/projects/myproject/main. I see no way of specifying the relative path of package.json with respect to getAppPath()
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How do I resolve "Cannot find module" error using Node.js?
This error can be encountered if you are require ing a module that has a missing or incorrect main ...
Read more >cannot find module [Node npm Error Solved] - freeCodeCamp
you're trying to import an item from a module you don't have installed in your project directory; you're importing some things from an...
Read more >Cannot find module 'X' error in Node.js | bobbyhadz
To solve the "Cannot find module" error in Node.js, make sure to install the package from the error message if it's a third-party...
Read more >How to resolve "Cannot find module" error in Node - Sabe.io
The issue is that Node is unable to find the module that you are trying to import into your Node application. The most...
Read more >Issues - GitHub
webpack module.js:471 throw err; ^ Error: Cannot find module '../package.json' at Function.Module._resolveFilename (module.js:469:15) at Function.Module.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

For the records, 1.4.1 works for my setting. Thanks!
So it turned out that
__filenamereturns the location ofelectron-reloadand not the parent filerequireing it. So I was wrong. But I changed it toconst mainFile = module.parent.filenameand I suppose it should work now. I’ll publish a new version and you can try it then.