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

135
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 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