-
Notifications
You must be signed in to change notification settings - Fork 15k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught ReferenceError: require is not defined #17241
Comments
👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can. To help make it easier for us to investigate your issue, please follow the contributing guidelines. |
The default for nodeIntegration changed from true to false as per our breaking changes document. |
How can I find the breaking changes document? |
The fix in main.js was done because of this: electron/electron#17241
in your index.js const w = new BrowserWindow({ |
You could use Browserify to fix your issue, had it been a web page or a website. But since you are using Electron to render html, you just need to set node integration to true under web preference: like shown here. |
Thanks! Have solved my problem. |
npm i @angular-devkit/build-angular -D |
Need to change webPreferences.nodeIntegration to true when new BrowserWindow |
Thanks @bokele You are a life saver. :) |
setting |
See electron/electron#17241 `nodeIntegration` now defaults to `false` so you'd just get an error message like > Uncaught ReferenceError: require is not defined
actually i added nodeIntergration = true but dosent work still |
@tolbxela Thanks a lot mate |
It didn't work for me because |
Assuming electron 12.0.0 set Something like...
reference: https://stackoverflow.com/a/66455544/4097181 |
@brntsllvn Adding webPreferences: {
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true,
} Works like a charm!! Thing is, do these other properties affect your application in any way? Regards, |
Hi guys, any idea how to debug which package/piece of code is triggering this error? Proposed solutions are hacks, they lead to an insecure behaviour, the app needs an actual update to have a more secure behaviour. But the problem is that it's quite difficult to identify the faulty code. |
where do you get this error ? I guess it is on runtime ? if you can open devtools on the running app then console error should contain the required information about the stack trace with the actual package causing it |
I'll try to share a screen but it seems to be obsfuscated by webpack dev server, despite having source maps. I'll check in production if the error is clearer. Yes runtime indeed. Edit: it basically look like in this Stack Overflow question: https://stackoverflow.com/questions/59537125/require-doesnt-appear-in-my-code-but-webpack-keeps-throwing-the-error-require |
from 5.0.0-beta.5 to 5.0.0-beta.1
macOS 10.14.3
4.0.7
Problem
Build and pack passed well, but after run app, I see an error in console
Uncaught ReferenceError: require is not defined - at Object.electron - at __webpack_require__
.Screenshots
Additional Information
We use Typescript, electron-builder, webpack.
The text was updated successfully, but these errors were encountered: