Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

296
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!