Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

194
Visualizações
Electron Create React App not loading after build

I've created a test react project with the npx create react app and added the electron.js file. I then run the build script and it was compiled successfully but when I try to run the .exe nothing shows and the console returns a Failed to load resource: net::ERR_FILE_NOT_FOUND.

electron.js

const { app, BrowserWindow } = require("electron");
const path = require("path");
const isDev = require("electron-is-dev");

function createWindow() {
  const mainWindow = new BrowserWindow({
    width: 1920,
    height: 1080,
    webPreferences: {
      preload: path.join(__dirname, "preload.js"),
    },
  });

  mainWindow.loadURL(
    isDev
      ? "http://localhost:3000"
      : `file://${path.join(__dirname, "../build/index.html")}`
  );

  mainWindow.webContents.openDevTools();
}

app.whenReady().then(() => {
  createWindow();

  app.on("activate", function () {
    if (BrowserWindow.getAllWindows().length === 0) createWindow();
  });
});

app.on("window-all-closed", function () {
  if (process.platform !== "darwin") app.quit();
});

EDIT: so I tried again from the start and managed to build with just the create-react-app however I've now changed some files with a Routes component and while in dev works fine when I build it nothing shows. console.log are shown but the component isn't.

routes.js

const routes = [
  {
    exact: true,
    path: "/",
    component: lazy(() => import("../test")),
  },
];

const renderRoutes = (routes) =>
  routes ? (
    <Suspense fallback={<div>Loading...</div>}>
      <Switch>
        {routes.map((route, i) => {
          const Layout = route.layout || Fragment;
          const Component = route.component;

          console.log({ Component });

          return (
            <Route
              key={i}
              path={route.path}
              exact
              render={(props) => (
                <Layout>
                  {route.routes ? (
                    renderRoutes(route.routes)
                  ) : (
                    <Component {...props} />
                  )}
                </Layout>
              )}
            />
          );
        })}
      </Switch>
    </Suspense>
  ) : null;

const Routes = () => {
  return renderRoutes(routes);
};

export default Routes;
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Problem might be in the fact, that you have changed name for one of the main files, for example electron searches for special filename when building. Please check your filenames.

This error means that file was not found. Either path is wrong or file is not present where you want it to be.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda