electronshoppinglist icon indicating copy to clipboard operation
electronshoppinglist copied to clipboard

addWindow.html: require is not defined

Open forcetrekker opened this issue 5 years ago • 5 comments

Hi Brad, First of all thank you for your awesome course!

Currently when we click on add item button on add window we get an error as require is not defined.

Robb and Israel had proposed a solution in your video to enable nodeIntegration in browserWindow with a parameter as:

new BrowserWindow(
        {
            webPreferences: {
                nodeIntegration: true
            }
        }
)

Adding this as an issue for tracking. :)

forcetrekker avatar Aug 08 '19 15:08 forcetrekker

Thank for the note @forcetrekker !!

Yasirunet avatar Sep 22 '19 19:09 Yasirunet

Hi guys, based on https://www.electronjs.org/docs/tutorial/security It is not appropriate to use the above solution, so is there any other alternative solution?

day2daychallenge avatar May 16 '20 14:05 day2daychallenge

Hi, facing the same issue: Uncaught ReferenceError: require is not defined Added the require.js file: https://requirejs.org/docs/release/2.3.6/minified/require.js in the main project directory and referenced it in addWindow.html as such:

Still issue not resolved. Any help will be appreciated, thanks!

gauravjoshi1998 avatar May 18 '20 08:05 gauravjoshi1998

@gauravjoshi1998 starting the version 12 of electron you must to pass the following props webPreferences: { nodeIntegration: true, contextIsolation: false, } when you create instance of BrowserWindow

glebpigulevsky avatar Sep 12 '21 06:09 glebpigulevsky

Hi guys, based on https://www.electronjs.org/docs/tutorial/security It is not appropriate to use the above solution, so is there any other alternative solution?

With my current understanding of the security documentation, the security issues arise when using content from external sources as mentioned here https://www.electronjs.org/docs/tutorial/security, "A security issue exists whenever you receive code from an untrusted source (e.g. a remote server)". So in this use case, this isn't causing security issues as log as we don't use any untrusted external sources.

El-Wumbus avatar Dec 11 '21 21:12 El-Wumbus