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

297
Vistas
i am getting an error when i try to write node js in electron
import React, { useEffect, useState } from 'react'
import Navbar from './Navbar';
import Cards from './Cards';

const NewsAPI = require('newsapi');
const newsapi = new NewsAPI('apikey');
const Home = () => {
    const [news, setNews] = useState();
    useEffect(() => {
      newsapi.v2.topHeadlines({
          sources: 'bbc-news,the-verge',
          q: 'bitcoin',
          category: 'business',
          language: 'en',
          country: 'us'
        }).then((response: any) => {
          setNews(response.articles);
          console.log(response.articles);
        });
    },[])
    return (
        <>
        <Navbar />
        <div id='cards'>
          {/* code */}
        </div>
        </>
    )
}

export default Home

I am using the electron-react boilerplate. When I try to run this code I am getting these errors :

Cannot GET /index.html
ERROR in ./node_modules/electron/index.js 2:13-28
Module not found: Error: Can't resolve 'path' in '/Users/monke/Stream/frontend/stream-app/node_modules/electron'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
        - install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "path": false }
 @ ./src/renderer/Home.tsx 36:17-36
 @ ./src/renderer/index.tsx 12:31-48

Although if i remove the node js code, the error goes away. Am I not supposed to write the node js code in the component file? If not where am I supposed to write it? If I write it somewhere else how am I supposed to send that information over to the component?

about 4 years ago · Juan Pablo Isaza
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