Skip to content
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

6.0.0-beta.56 throws error require is not defined in the console #2284

Closed
3 tasks done
RodPaDev opened this issue May 23, 2021 · 2 comments · Fixed by #2285
Closed
3 tasks done

6.0.0-beta.56 throws error require is not defined in the console #2284

RodPaDev opened this issue May 23, 2021 · 2 comments · Fixed by #2285
Labels

Comments

@RodPaDev
Copy link

Preflight Checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.

Issue Details

  • Electron Forge Version:
    6.0.0-beta.56
  • Electron Version:
    v12.0.9
  • Operating System:
    Windows 10 (20H2)
  • Last Known Working Electron Forge version::
    6.0.0-beta.55 with plugin-webpack 6.0.0-beta.54

Expected Behavior

No errors in console

Actual Behavior

The following error shows in console, can confirm this breaks react, but also shows in a clean installation of electron-forge

Uncaught ReferenceError: require is not defined
    at Object.url (index.js:332)
    at __webpack_require__ (index.js:361)
    at fn (index.js:548)
    at eval (parseURL.js?acf0:3)
    at Object../node_modules/webpack-dev-server/client/utils/parseURL.js (index.js:204)
    at __webpack_require__ (index.js:361)
    at fn (index.js:548)
    at eval (index.js?8389:24)
    at Object../node_modules/webpack-dev-server/client/index.js?http://0.0.0.0&port=3000 (index.js:118)
    at __webpack_require__ (index.js:361)

To Reproduce

Run npx create-electron-app my-new-app --template=webpack
Run cd my-new-app
Run npm start

The error should appear in the dev tools console

The result of the steps above: https://github.com/RodPaDev/beta.56-console-err

Additional Information

@RodPaDev RodPaDev added the bug label May 23, 2021
@RodPaDev
Copy link
Author

RodPaDev commented May 23, 2021

Adding target: 'web' in webpack.renderer.config.js solves this issue and can confirm it also works with React.
I have no clue if it has added any side effects.

Adding only webPreferences: { nodeIntegration: true } to the BrowserWindow options didn't work but having both works.

Maybe this should be added to the template file?

@RodPaDev
Copy link
Author

I am however, using target: ['web', 'electron-renderer'], using electron-renderer alone does not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant