navigator is not defined
See original GitHub issueIssue Description
When I start my electron app (npx electron main.js
), on this line, i have this error.
Electronjs version: v10.1.4
Code:
const { app, BrowserWindow } = require("electron");
const customTitlebar = require("custom-electron-titlebar");
function createWindow(){
const window = new BrowserWindow({
width: 1280,
height: 720,
resizable: false,
titleBarStyle: "hidden",
frame: false,
webPreferences: {
nodeIntegration: true,
},
});
new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex("#444"),
});
window.loadFile("../public/index.html");
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:6
Top Results From Across the Web
node.js - ReferenceError: navigator is not defined
I assume that the problem is that Navigator.geolocation is a Web API and doesn't work on node. Is there a way to mock...
Read more >ReferenceError: navigator is not defined · Issue #522 · vercel/swr
Bug report Description / Observed Behavior When building the app with NextJS in Jenkins, the build fails with the following error message: ...
Read more >Navigator is not defined----bug - Theia Community
navigator is a browser API. If you require code in the backend that ends up executing browser scripts you will get errors.
Read more >Getting "ReferenceError: navigator is not defined" in Next.js app
Getting error - ReferenceError: navigator is not defined error from Plasmic in development and production for our NextJS app
Read more >navigator is not defined react - You.com | The AI Search ...
If you're doing server side rendering then you need to call navigator in a function that is run on the client side. For...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I was able to fix this by including it after the react app render statement. Just put it at the end of your index.html
It looks like you’re instantiating TitleBar in the electron main process, rather than the renderer process (where it actually has access to the DOM). That is why it works when you added it into the
index.html
file.