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.

pluginManager.require results in an immediate exception - 'MODULE_NOT_FOUND'

See original GitHub issue

Hello,

I am trying to use the live-plugin-manager to allow users use different json-resume themes without needing to bundle them with my app. The themes are basically nodejs packages exposing a render method.

My code looks like this:

export const getLocalTheme = async (theme: IThemeEntry) => {
    try {
       await pluginManager.install(theme.name);
       const themePkg = await pluginManager.require(theme.name); // the NPM package name
        return themePkg;
    } catch (err) {
        console.log('Something went wrong', err)
    }
};

Calling getLocalTheme end in the catch block just after await pluginManager.require(theme.name) I get:

Error: Cannot find module 'fs'
    at Function.webpackEmptyContext [as resolve] (/Users/kmacha/Dev/kiss-my-resume/.webpack/main/index.js:23417:10)
    at PluginVm.isCoreModule (/Users/kmacha/Dev/kiss-my-resume/.webpack/main/index.js:24688:118)
    at PluginVm.sandboxResolve (/Users/kmacha/Dev/kiss-my-resume/.webpack/main/index.js:24645:18)
    at PluginVm.sandboxRequire (/Users/kmacha/Dev/kiss-my-resume/.webpack/main/index.js:24652:31)
    at Object.assign.resolve (/Users/kmacha/Dev/kiss-my-resume/.webpack/main/index.js:24596:25)
    at /Users/kmacha/Library/Application Support/kiss-my-resume/themes/jsonresume-theme-material/index.js:2:10
    at /Users/kmacha/Library/Application Support/kiss-my-resume/themes/jsonresume-theme-material/index.js:277:2
    at Script.runInContext (vm.js:127:20)
    at PluginVm.vmRunScriptInSandbox (/Users/kmacha/Dev/kiss-my-resume/.webpack/main/index.js:24554:16)
    at PluginVm.load (/Users/kmacha/Dev/kiss-my-resume/.webpack/main/index.js:24479:22) {
  code: 'MODULE_NOT_FOUND'
}

Needles to say I am in the electron environment and I build my app with the help of electron-forge. Here is the complete output, when I started my app with the DEBUG=* flag:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
davideicardicommented, Sep 3, 2020

Thanks @karlitos ! I’m closing the issue for now. Probably I need to investigate better why in some circustances (electron?, webpack?) some dependencies are not available (like fs and path) but I will probably create a dedicated issue.

1reaction
karlitoscommented, Sep 3, 2020

Hi, you are absolutely right. I think the author of this particular theme did a mistake putting those packages in a devDependencies. I would like to offer the users to use as many of those themes as possible, on the other hand I can’t and don’t want manage some 250+ 3rd party packages - I guess I will be going to try all the themes one-by-one and blacklist those, with dependency issues I can’t fix on my side.

Thank you thought for helping me and explaining how to use the static dependencies with live-plugin-manager - we might close this issue at this moment. Once again - great work you did here, saving me the necessity of bundling 25MB of NPM with my app.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failure Exception: ModuleNotFoundError: No module named ...
When I do so, the following error occurs: Result: Failure Exception: ModuleNotFoundError: No module named 'azure.storage'.
Read more >
Failure Exception: ModuleNotFoundError: No module named ...
Hello community,. I have developed an azure function locally from Visual Studio Code (VSC) that queries an API and that works very well...
Read more >
Drupal 9 updating issue - Drupal\Component\Plugin ...
Drupal 9 updating issue - Drupal\Component\Plugin\Exception\PluginNotFoundException: The "<whatever>" plugin does not exist. Needs work. Project ...
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