First of all I am new to nodejs and secondly below is my question. How to include nodejs net module in js which is loaded in html??
My js file looks like this.
The reason "require is not defined" is because "require" is a keyword of node.js, but it is not a keyword in browser.
Node.js is a virtual machine (or running context) for javascript, browser is also a virtual machine for javascript. But they are hugely different. You cannot use a keyword supported in one virtual machine in another virtual machine, just like you can use C/C++ on both Windows and Linux, but there are many libraries that are either in Linux only or Windows only.