leota / electron-angular4-sqlite3

Sample project to show how to build a desktop app using Electron, Angular 4 and Sqlite3
62 stars 33 forks source link

Error: require is not defined in index.html #16

Closed j4ys closed 5 years ago

j4ys commented 5 years ago

at first, I followed as given instruction to start electron app but during npm install electron was failing to install.

then I removed the electron from package.json and manually installed electron with the latest version.

now I am getting an error saying that require is not defined in index.html file at line 15 Uncaught ReferenceError: require is not defined at index.html:15

and another error is cannot read property ipcRenderer of undefined in AppComponent AppComponent_Host.html:1 ERROR TypeError: Cannot read property 'ipcRenderer' of undefined

leota commented 5 years ago

Hi @j4ys ,

do you have node-gyp globally installed? If not, can you please try npm i -g node-gyp and then try running npm install again with the original package.json?

Let me know

j4ys commented 5 years ago

I had node-gyp installed. I tried with a fresh cloned copy but now electron window doesn't appear.

leota commented 5 years ago

What do you mean? Does it compile but the window does not appear?

j4ys commented 5 years ago

yes, I changed show option in BrowserWindow constructor to true and now it's working but why it doesn't work after updating electron to the latest version?

leota commented 5 years ago

Glad to hear you solved it. BTW, I don't know why didn't work after electron update, probably it's not compatible with some other packages.

I'll try to make a new version with Angular 8 soon. Thanks for pointing issues.

j4ys commented 5 years ago

thanks for this great repo. I was struggling for a few days while setting up an electron app.

j4ys commented 5 years ago

just for general info, I found why require doesn't work with the latest version of the electron from electron v5 nodeIntegration in electron is disabled by default so we need to enable it.

stackoverflow reference

leota commented 5 years ago

Great, this will definitely help when I'll upgrade all the packages. Thanks a lot!