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

192
Visualizações
Node relationship with JS and the browser using NPM modules and browserify

I am a new StackOverflow user and I am starting to learn the back-end side of programming.
I use mostly JS client-side so the back-end side has some things that I need to clarify.

I have a problem regarding Node and its connection with the browser, even using browserify.
I know that a browser isn't Node's environment but I need to use that because I need to learn the little details of it.
The problem is, even though I use browserify in order to bound the several npm modules, everytime I try to require MySQL or HTTP or Express, errors occur.
If I use require('http') and/or require('express') this error occurs: TypeError: http.ServerResponse is undefined;
If, instead, I use require('mysql') this error occurs: TypeError: Net.createConnection is not a function

My questions are:
-How can I solve this?
-Those are errors relative to browserify or they would be the same without it, using an environment different from the browser?
I'll prefer not a straightforward solution but an explanation with the code if necessary.

Thank you very much in advance

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Modules such as mysql need low-level network interface. http is an abstraction over that network interface. So you really need net module, which is not avaliable in browser environment at all.

Browserify is just a semi-nodejs envirionment. It mocks up some of modules it can polyfill in browser.

You should install Node.js run your programm as such

node your_script.js
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