Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

293
Vistas
os.platform returns browser instead of actual OS - React & Electron

I am trying to retrieve the appdata folder location for the application, and since each os has a separate path for the appdata or application support folder, I tried retrieving the os type to specify which path to use. The issue is os.platform() returns 'browser'. I have tried running it on windows and mac, but they all return browser. If i run process.platform in electron.js it gives me the correct os, but in react I get browser. How can I get the proper OS?

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

In a browser you can use a combination of navigator.platform, navigator.userAgent, and navigator.userAgentData.platform to get the information you want, but it might take some testing and parsing.

AFAIK, navigator.userAgentData.platform is available only on Chrome/Chromium-based browsers, but gives the most straight-forward result when available.

Checking which platform you're using, rather than checking for specific features, is generally consider not to be a good idea -- but I've found it hard to avoid sometimes myself, especially when working around platform-specific quirks and bugs.

about 4 years ago · Juan Pablo Isaza Denunciar

0

This is because you are running process.platform in the renderer process.

In order to get the correct value you need to run platform.process either on main process (usually the background.js file) or via @electron/remote, like this:

window.require('@electron/remote').process.platform

@electron/remote's usage depends on your electron version, I recommend you to check @electron/remote readme.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Have you tried using Electron's app.getPath(name) method?

This method will return the users application data directory.

Only once the app is "ready" can you retrieve this path.

// Electron module(s).
const electronApp = require('electron').app;

// Application is now ready to start.
electronApp.on('ready', () => {

    // Get the users app data directory.
    let appData = electronApp.getPath('appData');

    // Get the users home directory.
    let home = electronApp.getPath('home');
})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda