0
votes

I'm having difficulty accessing lodash in an electron renderer. I'm new to Electron and understand that both the main process and the renderer (local html file) have access to node. I can require something native to node core such as fs and it works - when I try to require lodash, it returns an empty object. So far I have:

  • installed lodash from npm to the local project (using --save)
  • run electron-rebuild

I refresh the app and step through the debugger only to find that lodash is an empty object.

Am I missing something? Can you only run core node modules in a renderer?

1
Mention some more details. - Tirthraj Rao

1 Answers

0
votes

To use packages in the renderer, you simply have to load it as a dependency in your package.json file and require it by name. To make sure your dependencies are up to date:

  • add the module's latest version to the dependencies object of your package.json file.
  • delete your node_modules/folder
  • run npm install on your project folder

You should now be able to simply do require('module_name'); in your renderer.js file.