I've seen and did all steps in TypeError: window.require is not a function and Electron require() is not defined and many others.
I am using
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"concurrently": "^6.2.1",
"electron": "^14.0.0",
"electron-builder": "^22.11.7",
"electron-is-dev": "^2.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"sqlite3": "^5.0.2",
"wait-on": "^6.0.0",
"web-vitals": "^1.0.1"
},
I am following https://fmacedoo.medium.com/standalone-application-with-electron-react-and-sqlite-stack-9536a8b5a7b9 tutorial.
And when I type yarn electron-dev
the small window appears and looks ok
but I dunno how to debug - there is no console.
And when I access browser (opera or chrome) by localhost:3000 it gives me following
Currently it works in small app window (and doesn't work in browser) with such params:
mainWindow = new BrowserWindow({ width: 900, height: 680, webPreferences: {
nodeIntegration: true,
contextIsolation: false,
} });
If I remove the staff from index.js
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
and change the code in index.html
on something like
<!DOCTYPE html>
<html>
<head>
<title>Hello World App</title>
</head>
<body>
<h1>Hello World</h1>
<button id="btn">Click</button>
</body>
<script>
window.api.loadscript('./index.js');
</script>
</html>
Well I want to put some UI into it, so I can't just delete entry point to react. Answers from those links above didn't help me and I want to debug my app, not only see "small app window"
Thank in advance
ps I dare to open console in that small window app by adding
mainWindow.webContents.openDevTools();
but still I want to access it via browser