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.

Uncaught Exception: Cannot find module ../package.json

See original GitHub issue

NOTE: 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:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
marcoanconacommented, Jul 25, 2019

For the records, 1.4.1 works for my setting. Thanks!

0reactions
yan-fotocommented, Jul 15, 2019

So it turned out that __filename returns the location of electron-reload and not the parent file requireing it. So I was wrong. But I changed it to const mainFile = module.parent.filename and I suppose it should work now. I’ll publish a new version and you can try it then.

Read more comments on GitHub >

github_iconTop 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 >

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