Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

193
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda