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

132
Views
Call Node.js Script from React component
   const pythonProcess = spawn('python',["tiqi.py", "textFile.txt"]);
    
        pythonProcess.stdout.on('data',(data)=>{
            console.log(data.toString());
        })

Can I call and run that code by clicking a component button in my react project?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You cannot use node-based functions in a browser environment, to do such a thing in a proper way you should build an HTTP/HTTPS API for your react application and make requests from react to your API.

You can go through by googling building a simple node server based on express, and output your python script results in maybe .json file which you'll read with node (which will be sent on request from your react application).

Hope my answer will help you a bit.

about 4 years ago · Juan Pablo Isaza Report

0

Short answer: No. But other Node-based functions can be invoked using Browserify.

Refer to this link: https://github.com/browserify/browserify/issues/1816

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