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

298
Visualizações
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 à 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