-
Notifications
You must be signed in to change notification settings - Fork 112
Electron 5.0 changed defaults for nodeIntegration #9
Comments
Hi, Thanks for providing that piece of information about the change in defaults. Tomorrow I'll update the code with a change for that configuration change. |
Afternoon, Apologies for the delay. I've added the code change now. |
I am getting Uncaught ReferenceError: require is not defined at index.html:16
|
Hi @docdayao, Can you let me know:
Thanks. |
Thanks Paul for your email!
I am on Chapter 2 on section "Discovering the user's personal folder with
Node.js." and I am following the code in the book. I am using Electron. I
got to the Welcome to Lorikeet
Node.js - v14.16.0
OS - Windows 10.
I downloaded code in GitHub and tried Electron code here but I don't see
folders as well. I only see empty window with red empty bar where the
user's folder path should go...
cross-platform-desktop-applications/chapter-02/lorikeet-electron
at master · paulbjensen/cross-platform-desktop-applications · GitHub
<https://github.com/paulbjensen/cross-platform-desktop-applications/tree/master/chapter-02/lorikeet-electron>
I hope I can make it through each step.
Thanks!
…On Sun, Apr 4, 2021 at 9:52 PM Paul Jensen ***@***.***> wrote:
Hi @docdayao <https://github.com/docdayao>,
Can you let me know:
- What Chapter and version of the code you are running (the NW.js or
Electron example)
- What version of Node.js, and either Electron or NW.js you are running
- On what Operating System, and what version (e.g. Windows 10).
Thanks.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIJN2EW52KZGWQHYTW766HDTHBVIFANCNFSM4IHJMJAA>
.
|
Will take a look shortly. |
@docdayao what version of Electron are you running? I am going to try replicating the error with Electron 12.0.4 |
Yes thanks I have v12.0.2.
…On Mon, Apr 26, 2021 at 6:25 PM Paul Jensen ***@***.***> wrote:
@docdayao <https://github.com/docdayao> what version of Electron are you
running? I am going to try replicating the error with Electron 12.0.4
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIJN2EXSEEWIXO6D56TTRULTKU5TJANCNFSM4IHJMJAA>
.
|
@docdayao I have figured out the issue. Electron has made updates to improve the security around running apps. If you want to require Node.js libraries in the renderer process, then you have to pass these parameters to the mainWindow = new BrowserWindow({
webPreferences: { nodeIntegration: true, contextIsolation: false },
}); The |
Thanks Paul! I'll try this within the week. I also saw the latest Electron
version is 12.0.5.
…On Tue, Apr 27, 2021 at 3:58 PM Paul Jensen ***@***.***> wrote:
@docdayao <https://github.com/docdayao> I have figured out the issue.
Electron has made updates to improve the security around running apps. If
you want to require Node.js libraries in the renderer process, then you
have to pass these parameters to the BrowserWindow instance on line 17:
mainWindow = new BrowserWindow({
webPreferences: { nodeIntegration: true, contextIsolation: false },});
The contextIsolation parameter is the one that was missing. There is more
information at this link:
https://www.electronjs.org/docs/tutorial/quick-start#nodejs-api
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIJN2ETESRR262NHCWM2SRTTKZVCZANCNFSM4IHJMJAA>
.
|
I tried it and it works! Thanks for your help mate!
Hey do you have a second edition coming out?
…On Tue, Apr 27, 2021 at 4:53 PM Doc Dayao ***@***.***> wrote:
Thanks Paul! I'll try this within the week. I also saw the latest Electron
version is 12.0.5.
On Tue, Apr 27, 2021 at 3:58 PM Paul Jensen ***@***.***>
wrote:
> @docdayao <https://github.com/docdayao> I have figured out the issue.
>
> Electron has made updates to improve the security around running apps. If
> you want to require Node.js libraries in the renderer process, then you
> have to pass these parameters to the BrowserWindow instance on line 17:
>
> mainWindow = new BrowserWindow({
> webPreferences: { nodeIntegration: true, contextIsolation: false },});
>
> The contextIsolation parameter is the one that was missing. There is
> more information at this link:
> https://www.electronjs.org/docs/tutorial/quick-start#nodejs-api
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#9 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AIJN2ETESRR262NHCWM2SRTTKZVCZANCNFSM4IHJMJAA>
> .
>
|
@docdayao You're welcome. On the second edition, there isn't one planned, but if Manning Publications want a 2nd edition then it will happen. |
According to this StackOverflow post, as of Electron v5, the default for
nodeIntegration
changed fromtrue
tofalse
, so we need to explicitly enable it by changing the following line in main.js (chapter 2):mainWindow = new BrowserWindow();
to
mainWindow = new BrowserWindow({ webPreferences: { nodeIntegration: true } });
otherwise the script (in index.html) used to display the home folder will not work.
The text was updated successfully, but these errors were encountered: