forge icon indicating copy to clipboard operation
forge copied to clipboard

Improve error messaging for requireSearch failures

Open erickzhao opened this issue 3 years ago • 0 comments

Pre-flight checklist

  • [X] I have read the contribution documentation for this project.
  • [X] I agree to follow the code of conduct that this project uses.
  • [X] I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Problem description

Say I have a Forge app erick-forge-tester and I have a custom plugin within the src/ folder in my repo. If I write the wrong path to the local plugin, I get the following error message:

Could not find module with name: ./src/plugin-webpack/dist/. Make sure it's listed in the devDependencies of your package.json.

This is confusing because the second sentence implies that local modules are not supported without some package.json hacking, but the require-search module DEBUG statements clearly show that this is supported (and I just wrote my path wrong):

electron-forge:require-search failed to find a module in [
  './src/plugin-webpack/dist',
  '/Users/erick.zhao/Developer/electron/erick-forge-tester/src/plugin-webpack/dist',
  '/Users/erick.zhao/Developer/electron/erick-forge-tester/node_modules/src/plugin-webpack/dist'
]

Proposed solution

I believe other plug-and-play modules (makers and publishers) have the same error messages but use the same requireSearch helper.

We should make this error message more descriptive!

Alternatives considered

N/A

Additional information

No response

erickzhao avatar Oct 11 '22 20:10 erickzhao