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

273
Visualizações
Javascript: importing React from Electron renderer

I am using VSCode on Windows. I have set up a boilerplate ElectronJS app and want to use React for the UI. I have main.js, index.html, preload.js and renderer.js.

I have installed these and other packages (like babel) via npm. I see react and other packages in node_modules/ however I can't figure out how to get React imported.

Here is my project structure

node_modules/
.gitignore
index.html
main.js
preload.js
renderer.js

In my renderer.js file I have done as I see other people demonstrate:

import React from 'react';
import ReactDOM from 'react-dom';

In the Electron app's developer console I see: Uncaught TypeError: Failed to resolve module specifier "react". Relative references must start with either "/", "./", or "../".

So I have switched to:

import React from './node_modules/react'

(In the dev console: Failed to load resource: net::ERR_FILE_NOT_FOUND)

For all of these options (separately!):

import React from './node_modules/react/index.js'
import React from './node_modules/react/umd/react.development.js';
import React from import React from './node_modules/react/cjs/react.development.js';

(because it looks like that file reads a Node environment variable to export up either the Dev or Prod version, so it seemed like it might be my entry point) I get "The requested module ... does not provide an export named 'default'.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This will work:

import * as React from 'react';
import * as ReactDOM from 'react-dom';
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