Skip to content

Instantly share code, notes, and snippets.

@msafi
Last active May 28, 2025 17:10
Show Gist options
  • Save msafi/d1b8571aa921feaaa0f893ab24bb727b to your computer and use it in GitHub Desktop.
Save msafi/d1b8571aa921feaaa0f893ab24bb727b to your computer and use it in GitHub Desktop.
Electron Webpack `require is not defined`

If you're using Webpack to bundle your Electron app and you're getting require is not defined, and you don't want to set nodeIntegration to true for security, change the target of your webpack bundle from electron-renderer to web. That way webpack won't be trying to look for things like require and module in the environment.

I found this solution after reading this comment SimulatedGREG/electron-vue#644 (comment)

@samvv
Copy link

samvv commented Oct 8, 2021

That's what I needed; thanks!

@amirrahmani76
Copy link

that's worked for me, thanks

@liuuuk311
Copy link

Thank you so much! It worked for me too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment