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

191
Views
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 answers
Answer question

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